The Grey Labyrinth is a collection of puzzles, riddles, mind games, paradoxes and other intellectually challenging diversions. Related topics: puzzle games, logic puzzles, lateral thinking puzzles, philosophy, mind benders, brain teasers, word problems, conundrums, 3d puzzles, spatial reasoning, intelligence tests, mathematical diversions, paradoxes, physics problems, reasoning, math, science.

   
The Grey Labyrinth Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    RegisterRegister  
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

File Renaming Help

 
Reply to topic    The Grey Labyrinth Forum Index -> Science, Art, and Culture
View previous topic :: View next topic  
Author Message
Logain
Stretch Armstrong



PostPosted: Fri Sep 05, 2003 12:24 pm    Post subject: 1 Reply with quote

OK, I have small problem with renaming files. I have about 6000 files I need to rename and I would hope there's some utility out there (since I can't figure out how to do it with DOS wildcards) to make this easier.

The files are all named in the following format:

xxxxyyyyyy.zzz

where the number of ys changes from file to file. I simply want to remove the first four characters of each file (represented by the xs).

Anyone know an easy way?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Death Mage
Raving Lunatic



PostPosted: Fri Sep 05, 2003 12:35 pm    Post subject: 2 Reply with quote

Last time I had to do something like that, I basically had to use a program that made a macro, a series of keystrokes, and repeated it over and over and over. And even then, I could only do it in small blocks. :\ It's not fun to do.
Back to top
View user's profile Send private message
Antrax
ESL Student



PostPosted: Fri Sep 05, 2003 1:02 pm    Post subject: 3 Reply with quote

Okay, I feel really stupid. There is a way to do it with DOS for command, but I just can't figure it out. What's worse, I get the exact same problem every time I have to do a mass rename or something of the sort, I solve it every time, but I never seem to remember how I did it last time. Just type "help for" and "help set" at DOS prompt, you can probably figure it out. I'm too tired, apparently ~annoyed at self~
Antrax

------------------
"Look, that's why there's rules, understand? So that you think before you break 'em" - Lu-Tze, Thief of Time
Back to top
View user's profile Send private message Send e-mail Visit poster's website
HyToFry
Drama queen



PostPosted: Fri Sep 05, 2003 1:30 pm    Post subject: 4 Reply with quote

I'll look at it when I get to work. It is possilble.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Chuck
Daedalian Member



PostPosted: Fri Sep 05, 2003 2:41 pm    Post subject: 5 Reply with quote

I'd write a short BASIC program the made a large batch file that renamed them one by one if I couldn't figure out how to do it with a DOS command.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
HyToFry
Drama queen



PostPosted: Fri Sep 05, 2003 3:10 pm    Post subject: 6 Reply with quote

Apparently you can't. You can strip off the right chars of a file name, but not the left ones...

weird.

http://www.shadowsource.org/keys/progs/renfile.htm

Try that.

You can also try this, but I couldn't get it to download.
http://www.simtel.iif.hu/pub/pd/61453.html
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
MBA
Daedalian Member



PostPosted: Fri Sep 05, 2003 3:33 pm    Post subject: 7 Reply with quote

You can do it via an asp page on an IIS web server. Just use the FileSystemObject (read more about FSO at [url=http://www.aspfaqs.com).]http://www.aspfaqs.com).[/url] Read the filename into a variable and then use the LEFT, RIGHT and MID functions to rename the file as you desire.
Back to top
View user's profile Send private message
HyToFry
Drama queen



PostPosted: Fri Sep 05, 2003 4:11 pm    Post subject: 8 Reply with quote

Never mind this post. I was in the wrong thread or something.

[This message has been edited by HyToFry (edited 09-05-2003 12:16 PM).]
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
mole
Subterranean Member



PostPosted: Fri Sep 05, 2003 4:14 pm    Post subject: 9 Reply with quote

Is there a shell command in BASIC to do the same thing as Chuck's idea? There's no reason to build a batch file and run that if you can run commands directly from BASIC.
Back to top
View user's profile Send private message Send e-mail
HyToFry
Drama queen



PostPosted: Fri Sep 05, 2003 4:19 pm    Post subject: 10 Reply with quote

here's something you could do.

Code:
FOR %i in (*.*) DO echo rename %i %i >> rename.bat


Now open that up in a text editor capable of replacing strings.

If the files are named *.html, then do this:
Find ".html xxxx" and replace with ".html "

Now save it, and run the batch file.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
HyToFry
Drama queen



PostPosted: Fri Sep 05, 2003 4:21 pm    Post subject: 11 Reply with quote

Just make sure that you include the extension in that search and replace bit. Otherwise you'll end up with a batch file that renames yyyy.ext to yyyy.ext.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
HyToFry
Drama queen



PostPosted: Fri Sep 05, 2003 4:48 pm    Post subject: 12 Reply with quote

Or.. even better.

Code:
FOR %i in (*.*) DO echo rename %i ~%i >> rename.bat


Then just search/replace ~yyyy with nothing.

------------------
Whatever poison's in this bottle, will leave me broken sore and stiff... but it's the genie at the bottom, who I'm sucking at; he owes me one last wish.



[This message has been edited by HyToFry (edited 09-05-2003 12:50 PM).]
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Vinny
Promiscuous enough



PostPosted: Fri Sep 05, 2003 5:57 pm    Post subject: 13 Reply with quote

Do what MBA said, Logain. Use ASP if you have either Windows 2000 or Windows XP and have the component "Internet Information Servicess (IIS)" installed.

If you do, just go to c:\inetpub\wwwroot\ and create a text file using notepad, with the extension .asp.

Let's name it test.asp for illustration purpose.

Open the text file, then copy and paste the following code into the file, and save.

code:


<%
Option Explicit

Dim filesys, demofolder, fil, filecoll, filist
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofolder = filesys.GetFolder("c:\temp\")
Set filecoll = demofolder.Files
For Each fil in filecoll
filist = filist & fil.name
filist = filist & "<BR>"
Next

Response.Write filist
%>



To run it, open a web browser, the go the url http://localhost/test.asp

Tell me if that works. If it does, it should list all the content of a c:\temp\ folder (if the folder exists). You can then modify the code to do all sort of neat stuff, like mass renaming.

Use http://www.devguru.com (Quick References -> VBScript) for reference. For more things you can do with the FileSystemObject, look at the Objects section of that site.

http://www.devguru.com/Technologies/vbscript/quickref/filesystemobject.html
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
HyToFry
Drama queen



PostPosted: Fri Sep 05, 2003 5:59 pm    Post subject: 14 Reply with quote

my way is still easier.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Logain
Stretch Armstrong



PostPosted: Fri Sep 05, 2003 6:08 pm    Post subject: 15 Reply with quote

Hey Hy, that seems like it will work great.

I'll have to first cut and paste the results in an Excel spreadsheet since the yyyy is different for each file, so deleting a column is easier there than a search/replace, then paste back into the .bat file. Thanks for the tip.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Logain
Stretch Armstrong



PostPosted: Fri Sep 05, 2003 6:09 pm    Post subject: 16 Reply with quote

Sorry Vinny, just noticed your post after already replying. I had just tested Hy's method so I already know what I'm doing there and it worked just fine.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
HyToFry
Drama queen



PostPosted: Fri Sep 05, 2003 6:14 pm    Post subject: 17 Reply with quote

It's a damn shame that FOR can't handle two commands....

Code:
for %i in (*.*) DO set tempfile=%i|rename %i %tempfile:~4,99%


In theory, that would work... but it doesn't because for can't handle the multiple commands.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
extropalopakettle
No offense, but....



PostPosted: Fri Sep 05, 2003 6:58 pm    Post subject: 18 Reply with quote

Can't you have the for loop call a bat file, and have that do the two commands?
Back to top
View user's profile Send private message
HyToFry
Drama queen



PostPosted: Fri Sep 05, 2003 7:22 pm    Post subject: 19 Reply with quote

Yup, but then you have to write a bat file... which is just as easy as what was already done... I think.

Too late now anyway.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous: by   
Reply to topic    The Grey Labyrinth Forum Index -> Science, Art, and Culture All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Site Design by Wx3