PC Review


Reply
Thread Tools Rate Thread

Batch rename, changing length of filename

 
 
Scott Falkner
Guest
Posts: n/a
 
      3rd Mar 2004
Is there a was to batch rename files, changing the length
of the filename?

I have a lousy scanner that can scan a lot of pictures in
one go. The scans are
named "scan0001.tif", "scan0002.tif", etc. This is
uncongifurable (yes, the software for the lousy scanner is
lousy). I would like to rename the
files "01.tif", "02.tif", etc. I know I can enter DOS and
rename the file with a RENAME" command, but I can't seem
to change the length of the filename.
 
Reply With Quote
 
 
 
 
Drew Cooper [MSFT]
Guest
Posts: n/a
 
      3rd Mar 2004
My solution is not generalized but it will remove two zeros following "scan"
in the filenames in a given directory. I think that solves this specific
problem. And it does it using only tools that ship with the OS.

At the cmdline:
dir /b /a-d >oldnames.txt
for /f %i in ('type oldnames.txt') do echo move %i x%i >>changem.bat
Then open changem.bat with Notepad, replace-all "xscan00" with "scan", and
save.
Run changem.bat.

And you can get rid of oldnames.txt and changem.bat when you're done, of
course.
--
Drew Cooper [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.


"Scott Falkner" <(E-Mail Removed)> wrote in message
news:38e201c40140$edb5b5e0$(E-Mail Removed)...
> Is there a was to batch rename files, changing the length
> of the filename?
>
> I have a lousy scanner that can scan a lot of pictures in
> one go. The scans are
> named "scan0001.tif", "scan0002.tif", etc. This is
> uncongifurable (yes, the software for the lousy scanner is
> lousy). I would like to rename the
> files "01.tif", "02.tif", etc. I know I can enter DOS and
> rename the file with a RENAME" command, but I can't seem
> to change the length of the filename.



 
Reply With Quote
 
Phil Robyn [MVP]
Guest
Posts: n/a
 
      3rd Mar 2004
Scott Falkner wrote:

> Is there a was to batch rename files, changing the length
> of the filename?
>
> I have a lousy scanner that can scan a lot of pictures in
> one go. The scans are
> named "scan0001.tif", "scan0002.tif", etc. This is
> uncongifurable (yes, the software for the lousy scanner is
> lousy). I would like to rename the
> files "01.tif", "02.tif", etc. I know I can enter DOS and
> rename the file with a RENAME" command, but I can't seem
> to change the length of the filename.


From the CMD prompt (assuming ENABLEDELAYEDEXPANSION is in effect):

for %a in (c:\yourdir\scan*.tif) do (set old=%~nxa&echo ren c:\yourdir\!old! !old:~6!)

If the preceding appears to do what you intend, remove the word 'echo'
to actually rename the files.

If you use the preceding in a batch file, change all '%' to '%%'. For
information about 'ENABLEDELAYEDEXPANSION', type 'CMD /?' (without
the apostrophes) at a CMD prompt.

--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename filename.csv Rob Microsoft Excel Programming 2 15th Feb 2010 03:59 PM
filename length in XP pjohnst0n@kol.co.nz Windows XP General 12 10th May 2007 09:54 PM
Filename length error =?Utf-8?B?anNoYWZmZXI=?= Windows XP General 2 6th Feb 2007 05:44 AM
Maximum filename length. 218? 211? =?Utf-8?B?TWlrZSBPLg==?= Microsoft Excel Programming 0 4th Nov 2005 07:18 PM
cannot rename 'filename.wmv.tmp' Woolie1 Microsoft Frontpage 1 2nd Feb 2004 03:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:23 PM.