Renaming items in a folder

J

James Silverton

Hello, All!

I could do this with Unix so easily but I cannot think how to
rename all (or at least a good number) of the items in a folder
with Windows. A typical example would be the automatic picture
numbers from a digital camera, like DSC00831. I would like to
simply type the names, line by line with a word processor, and
then replace the picture numbers. Has anyone any easy
suggestions or is my knowledge of Windows even more meager than
I suspect?

TIA

James Silverton
Potomac, Maryland, USA
 
J

Jerry

You open Explorer, select and highlight the file to be renamed, hit F2, type
the new name in the box. Repeat for each file to be renamed.
 
J

James Silverton

Jerry wrote on Thu, 29 Dec 2005 13:37:16 -0800:

Thanks but that's the tedious process I was trying to avoid:)

message
Hello, All!

I could do this with Unix so easily but I cannot think how to
rename all (or at least a good number) of the items in a
folder with Windows.
J> message
James Silverton.
 
J

James Silverton

John wrote on Thu, 29 Dec 2005 21:40:15 -0000:

J>
http://www.microsoft.com/windowsxp/using/digitalphotography/learnmore/renamephotos.mspx

J> Regards

J> John

J> message ??>> Hello, All!
??>>
??>> I could do this with Unix so easily but I cannot think how
??>> to rename all (or at least a good number) of the items in
??>> a folder with Windows.

Again, I'm afraid I also knew about that useful technique but
what I would like to do is use quite different descriptive names
for each file. I know Explorer will do it but I find doing the
names one by one to be tedious. Just to avoid misunderstanding,
I might have:_
DSN00675
DSN00677
DSN00684.............
and I would like to replace them by say:
On the swings
How did the dog get in?
Going home..........

Typing the list of names with even someting like Word Pad is not
particularly time consuming but I can't think how to use the
list in the folder directory. If only the directory were an
Excel file!

James Silverton.
 
D

David Candy

dir /a /b "c:\somewhere" >> "%userprofile%\desktop\filelist.txt"

ren "filename1" "filename2"
 
J

James Silverton

David wrote on Fri, 30 Dec 2005 09:08:05 +1100:

dir /a /b "c:\somewhere" >>
"%userprofile%\desktop\filelist.txt"

ren "filename1" "filename2"


DC> ren "filename1" "filename2"

DC> --
DC> -----------------------------------------------------------
DC> Goodbye Web Diary
DC>
http://margokingston.typepad.com/harry_version_2/2005/12/thank_you_and_g.html#comments
DC> =================================================
DC> message ??>>
??>> Typing the list of names with even something like Word Pad
??>> is not particularly time consuming but I can't think how
??>> to use the list in the folder directory.

Thank you David!

Now that looks good! It could be done by setting up a Script
file I guess but I tend to forget about those.


James Silverton.
 
D

David Candy

In Word using Find and Replace it is a cinch. ^p is a paragraph in word. So in File list text

Find
^p
Replace
" "^pren "

Prefixes all but the first line with

ren "

and adds

" "

to the end of the line (check the last line for a spurious entry)

so all you do is go to end of each line and type

newfilename"

Name the new file something.bat. Test it on a copy of your data.
 
J

James Silverton

David wrote on Fri, 30 Dec 2005 09:29:36 +1100:

DC> Find
DC> ^p
DC> Replace
DC> " "^pren "

DC> Prefixes all but the first line with

DC> ren "

DC> and adds

DC> " "

DC> to the end of the line (check the last line for a spurious
DC> entry)

DC> so all you do is go to end of each line and type

DC> newfilename"

DC> Name the new file something.bat. Test it on a copy of your
??>> Thank you David!
??>>
??>> Now that looks good! It could be done by setting up a
??>> Script file I guess but I tend to forget about those.
??>>
??>> James Silverton.
??>>

Again, many thanks and I'll give it a try very soon!

James Silverton.
 
B

billious

James Silverton said:
John wrote on Thu, 29 Dec 2005 21:40:15 -0000:

J>
http://www.microsoft.com/windowsxp/using/digitalphotography/learnmore/renamephotos.mspx

J> Regards

J> John

J> message ??>> Hello, All!
??>>
??>> I could do this with Unix so easily but I cannot think how
??>> to rename all (or at least a good number) of the items in
??>> a folder with Windows.

Again, I'm afraid I also knew about that useful technique but what I would
like to do is use quite different descriptive names for each file. I know
Explorer will do it but I find doing the names one by one to be tedious.
Just to avoid misunderstanding, I might have:_
DSN00675
DSN00677
DSN00684.............
and I would like to replace them by say:
On the swings
How did the dog get in?
Going home..........

Typing the list of names with even someting like Word Pad is not
particularly time consuming but I can't think how to use the list in the
folder directory. If only the directory were an Excel file!

James Silverton.

Hmm..so he wants an excel file, does he?

Well, before the excel file generation path, try this batch:


[1]@echo off
[2]echo @echo off>jsg.bat
[3]for /f "DELIMS=" %%i in ( 'dir/S/b/a-d "r:\directory\*.*" ' ) do echo ren
2^>nul "%%~dpnxi"
"%%~nxi">>jsg.bat

Each line begins [number]. Lines will be wrapped in transmission and need to
be rejoined. The [number] at the beginning of each line needs to be removed.

This batch processes r:\directory, finding all files (*.*) in the
directory-tree (remove the "/S" switch from after the DIR to scan the target
directory only) and creating a file (jsg.bat) which has the structure

@echo off
ren 2>nul "r:\directory\file1.ext" "file1.ext"
ren 2>nul "r:\directory\file2.ext" "file2.ext"
ren 2>nul "r:\directory\file3.ext" "file3.ext"
....

which can then be text-edited (using EDIT or Notepad, not wordpad as wordpad
tends to save unwanted formatting data...) to create your new filenames.

The "2>nul" suppresses any STDERR messages that may be created when the
batch is run. Remove the 2^>nul from [3] if you want to see these messages
(which can be useful if the filenames contain some characters to which DOS
is sensitive - like % or & for instance [best to avoid these characters])

Now if you really want it in Excel format, change the batch to:

[1]@echo off
[2]if exist jsg.csv del jsg.csv
[3]for /f "DELIMS=" %%i in ( 'dir/S/b/a-d "r:\directory\*.*" ' ) do echo
"%%~dpnxi",
"%%~nxi">>jsg.csv

which will create jsg.csv with two quote-delimited, comma-separated columns.
Leave out the ,"%%~nxi" part to create one column if that's what you want.

HTH

....Bill
 
J

James Silverton

billious wrote on Fri, 30 Dec 2005 23:14:36 +0800:


b> Hmm..so he wants an excel file, does he?

Thanks billious and David!

I've actually got the process and batch files to work after
learning (or perhaps relearning) about the preparation, care and
feeding of batch files. I had completely forgotten that there
was a command prompt instruction Edit :) I also had to refresh
my memory about the components of batch files and to be careful
that my batch file was named correctly. It's amazing how much
I've forgotten about Basic including Rem for comments!

I found that a fairly efficient process for a large number (40+)
of pictures was to use the dir listing to make a data input to
an Excel file and then put the new names in a second column of
the file. This file could then be copied with an unformatted
paste to Word for a variant of David's suggestion. The whole
thing is quite simple and rapid tho' two windows or a print out
of the directory listing is useful. It may not be much more
efficient than a file by file change in Windows but the whole
list can be given some thought before a final committal.

My comment about Excel was just a Unix oriented wish that folder
directories could be editable files. I did know how to make the
Excel file above but thanks again to everyone!

A Good New Year to everyone!

James Silverton.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top