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