Travel Technology - A fast way to rename lots of files?




deubster
Aug 3, 09, 2:57 pm
The problem: I've just downloaded about 400+ expense reports from our online reporting system (weekly reports + special ones, for the last 7 or so years). They are PDF files with the report date as the name, e.g., "1-15-03.pdf", "1-15-04.pdf", "1-15-05.pdf", etc.

I want to rename these in the form of "2009-07-31.pdf" before I start the arduous process of examining them for a few things (we have a compensation issue at play). This way, I can handle them chronologically.

Sorting the directory by date is of no value, as they all downloaded with today's date.

Using Windows or DOS to rename will take me hours, and I'm about to fall asleep thinking about it. Are there any quickie file manager utilities or other methods that would help?


ScottC
Aug 3, 09, 3:19 pm
Try this utility:

http://www.bulkrenameutility.co.uk/Download.php

Alternatively, do a dir > rename.bat, then import the file into Excel and built your own BAT file. Each line will have to be renamed to run a command to ren(ame) the old file name into the new one. Won't take more than 10 minutes to build that batch file. When done in excel, save as plain text and run it. Be sure to run it on a copy of the files, just in case...

jonesing
Aug 3, 09, 3:29 pm
Also take a look at
http://www.sherrodcomputers.com/products_filerenamer.cfm


deubster
Aug 3, 09, 3:44 pm
Try this utility:

http://www.bulkrenameutility.co.uk/Download.php

Alternatively, do a dir > rename.bat, then import the file into Excel and built your own BAT file. Each line will have to be renamed to run a command to ren(ame) the old file name into the new one. Won't take more than 10 minutes to build that batch file. When done in excel, save as plain text and run it. Be sure to run it on a copy of the files, just in case...

Thanks for the replies, both of you.

Scott - actually, it took me less than 5 minutes to build the batch. Worked like a charm. As soon as I saw your reply, I said, "Duh! I know how to do that." That's what happens to your brain after 4 hours of opening a report online, exporting to pdf, downloading, then the next one, 400 times.

Once again, thanks. ^

ScottC
Aug 3, 09, 3:46 pm
Thanks for the replies, both of you.

Scott - actually, it took me less than 5 minutes to build the batch. Worked like a charm. As soon as I saw your reply, I said, "Duh! I know how to do that." That's what happens to your brain after 4 hours of opening a report online, exporting to pdf, downloading, then the next one, 400 times.

Once again, thanks. ^

DOS is a lost art :)

rh314
Aug 3, 09, 4:13 pm
Try this utility:

http://www.bulkrenameutility.co.uk/Download.php

Alternatively, do a dir > rename.bat, then import the file into Excel and built your own BAT file. Each line will have to be renamed to run a command to ren(ame) the old file name into the new one. Won't take more than 10 minutes to build that batch file. When done in excel, save as plain text and run it. Be sure to run it on a copy of the files, just in case...

+1.

That's a nifty idea. I'd personally do it with Cygwin and emacs, and it would take about a minute. But using Excel is a good idea if one doesn't have a handy UNIX-like shell. In fact, I was so taken by this idea that I did it on a test case. So although the OP has clearly already figured this out, it may help somebody else.

1. "dir>file.bat" and open the bat file, as ScottC says.

2. When you import, choose "delimited" and use "space" as a delimiting character.

3. Might want to get rid of the first few rows, plus any row that says "<DIR>" in the fourth column. And the last few rows.

4. Then kill the first four columns (the file name is in the fifth).

5. Insert a new "A" column with the word "ren" in each cell.

6. Now you'll need a few helper columns. Say the filename is in cell B1 with the format m-d-yy.pdf, where "m" can be one or two digits, "d" can be one or two digits, and "yy" is two digits.

Use the following helper formulas:

For C1: ="20"&mid(B1,find(".",B1)-2,2)
For D1: =left(B1,find("-",B1)-1)
For E1: =rept(0,2-len(D1))&D1
For F1: =mid(B1,find("-",B1)+1,find(".",B1)-find("-",B1)-4)
For G1: =rept(0,2-len(F1))&F1
For H1: =C1&E1&G1&".pdf"

Now copy H1 and paste just the values into I1.

Copy down and make sure it's working the way it should. When I did it, I combined the above formulae into single cell, but that was kind of a pain to debug. This way you should see if things aren't working quite right.

7. If it works, then now delete columns C through H.

8. Save and execute!

dgwright99
Aug 3, 09, 4:16 pm
DOS is a lost art :)

Does that make us lost artists ? :D

sbm12
Aug 3, 09, 4:20 pm
If you want to save most of the "clean-up" of the text file that you generate try dir /b instead of just plain dir. The /b, or "bare" switch gives you just the file names, without all the extra junk. @:-)

cordelli
Aug 3, 09, 4:22 pm
Same as the post above, I just typed it slower.

Deleted

riteshraja
Aug 3, 09, 6:29 pm
A little known fact of windows is you can select all the files in explorer rename one and it automatically renames all the files. For example if you were to select files names 1,2,3 and rename them after selecting all of them they would be renamed to test(1), test(2), test(3) ..

I often do this for the pictures folder.

allset2travel
Aug 3, 09, 8:00 pm
DOS is a lost art :)

Indeed!

riteshraja
Aug 3, 09, 8:36 pm
Indeed!

And for good reason. :D

PorkRind
Aug 3, 09, 8:43 pm
Can I play too?

c> perl -e "opendir DIR,q(.);foreach (readdir DIR) {rename $_,sprintf q(%4d-%02d-%02d%s),$3+2000,$1,$2,$4 if m/(\d+)-(\d+)-(\d+)(.*)/}" *

Of course, Perl is mandatory ;)

DenverBrian
Aug 3, 09, 8:47 pm
Heck, I still use XCOPY to back up my data to an external drive. :D :D :D

Middle_Seat
Aug 3, 09, 9:09 pm
I think that rh314's simple-looking instruction
1. "dir>file.bat" and open the bat file
hides a lot of complexity for those not knowledgeable in DOS.

I use the previously-mentioned Bulk Rename a lot. It's powerful, once you figure it out.

rh314
Aug 4, 09, 1:33 am
...
Of course, Perl is mandatory ;)

Words to live by :-)

dingo
Aug 4, 09, 8:26 am
Heck, I still use XCOPY to back up my data to an external drive. :D :D :D

I do as well, though I just downloaded a copy of RoboCopy from MS yesterday; haven't used it yet, but it has a UI on the xcopy functionality. Sounds cool if it works. Otherwise xcopy or xcopy32 will always be in my quivver.

sbm12
Aug 4, 09, 8:53 am
I do as well, though I just downloaded a copy of RoboCopy from MS yesterday; haven't used it yet, but it has a UI on the xcopy functionality. Sounds cool if it works. Otherwise xcopy or xcopy32 will always be in my quivver.Even without the UI (which I've never used) robocopy is better than xcopy. It is like xcopy on steroids. Lots of useful additional features, like scheduled differential copies based on time or byte changes and other fun things. I'm a big fan.

DenverBrian
Aug 4, 09, 9:17 am
Even without the UI (which I've never used) robocopy is better than xcopy. It is like xcopy on steroids. Lots of useful additional features, like scheduled differential copies based on time or byte changes and other fun things. I'm a big fan.Hmmm. Doesn't look like it's for Vista; and I'm telling you, nothing is simpler than a one-line batch file.

sbm12
Aug 4, 09, 12:21 pm
Hmmm. Doesn't look like it's for Vista; and I'm telling you, nothing is simpler than a one-line batch file.

:confused:

Robocopy is included in the Vista bits; there is nothing to download.

DenverBrian
Aug 4, 09, 12:55 pm
:confused:

Robocopy is included in the Vista bits; there is nothing to download.Oh, well, that's totally different. :D :D :D Sorry, I just web surfed to learn about RoboCopy and the only references given were for XP, plus the original reference upthread was to downloading a copy - I had no idea it was included in Vista.

Think I'll stick with XCOPY in any event. DOS rules, to quote someone.

sbm12
Aug 4, 09, 4:10 pm
Think I'll stick with XCOPY in any event. DOS rules, to quote someone.

Robocopy is very much a command-line program, despite the comments above about the GUI. Give it a look; you might be surprised just how flexible and functional it is. ;)

riteshraja
Aug 4, 09, 5:16 pm
Robocopy is very much a command-line program, despite the comments above about the GUI. Give it a look; you might be surprised just how flexible and functional it is. ;)

Exactly. It been my preferred way of backing up my laptop for the last 5-6 years.

robocopy d:\my_documents f:\my_documents_backup /s /e /eta /xf *itunes* *mp3* /xd *itunes* *temp* *tmp* /fft /maxage:30

SylviaCaras
Aug 4, 09, 6:40 pm
deubster: PDF files with the report date as the name, e.g., "1-15-03.pdf", "1-15-04.pdf", "1-15-05.pdf" ... this way, I can handle them chronologically.


Would it be possible to sort within the name field, since there are hyphens to separate, instead of renaming? By year, then month, then day?

I seem to remember being able to do that, but that was before Windows.

Sylvia

rh314
Aug 5, 09, 12:08 am
Exactly. It been my preferred way of backing up my laptop for the last 5-6 years.

robocopy d:\my_documents f:\my_documents_backup /s /e /eta /xf *itunes* *mp3* /xd *itunes* *temp* *tmp* /fft /maxage:30

I'd been using rsync via cygwin. Pretty similar to your usage of robocopy, but based on the UNIX command.

But recently I've started using dropbox (getdropbox.com). It's a user interface layer built atop Amazon S3 cloud storage. You pay for 50GB of storage ($100/year), but you get as much transfer bandwidth as you need.

I defined a dropbox folder inside my "My Documents" folder.

Caveat: you have to make sure your various programs save your work inside the dropbox folder. Plus, this doesn't backup information in other places, if you care about things like Opera bookmarks, etc.


But now, everytime I touch a file in my dropbox folder, it gets auto-updated to the cloud, and dropbox even does versioning of my files for me. An added benefit: On any other computer I have, I just define a dropbox folder, and it gets automatically synced, live.

It took a while to do the initial synchronization, but now, "it just works."

sbm12
Aug 5, 09, 6:54 am
It took a while to do the initial synchronization, but now, "it just works."
And when you need to recover your content it will take forever, just like it did for the initial sync. But we're getting VERY OT now. Let's try to stay focused on our love of random DOS, PERL and *nix commands here. ;)



SEO by vBSEO 3.2.0