Truncate file names?

Forum Windows XP : Windows XP General Discussion - Truncate file names?

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

Archived from groups: microsoft.public.windowsxp.basics (More info?)

 

I have a series of 200 files with file names in the format 00000### where ###
is a 3-digit number. I'd like to find an easy way to truncate the leading
zeros so that the file name is just ###. I need to preserve the actual
number as opposed to issuing a new series of sequential numbers. Any ideas?
Thanks!

Sponsored Links
Register or log in to remove.

Archived from groups: microsoft.public.windowsxp.basics (More info?)

 

"JRSNHECI" <JRSNHECI@discussions.microsoft.com> wrote in message
news:ACA60D76-E791-4A1E-A016-834F59FAB434@microsoft.com...
>I have a series of 200 files with file names in the format 00000### where
>###
> is a 3-digit number. I'd like to find an easy way to truncate the leading
> zeros so that the file name is just ###. I need to preserve the actual
> number as opposed to issuing a new series of sequential numbers. Any
> ideas?
> Thanks!

A batch file renaming programme will do it for you. There are several free
and shareware out there. Try a few freebies first. A good place to start
is here - http://www.pricelessware.org/theli [...] %20Renamer -
click link for Files: Renamer or simply scroll down. There are several with
good descriptions for each. Good luck.
Bruce

Reply to Bruce

Archived from groups: microsoft.public.windowsxp.basics (More info?)

 

Personally I like this one, and before you ask, no, I'm not on commission!

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




"JRSNHECI" <JRSNHECI@discussions.microsoft.com> wrote in message
news:ACA60D76-E791-4A1E-A016-834F59FAB434@microsoft.com...
>I have a series of 200 files with file names in the format 00000### where
>###
> is a 3-digit number. I'd like to find an easy way to truncate the leading
> zeros so that the file name is just ###. I need to preserve the actual
> number as opposed to issuing a new series of sequential numbers. Any
> ideas?
> Thanks!

Reply to Anonymous

Archived from groups: microsoft.public.windowsxp.basics (More info?)

 

"JRSNHECI" <JRSNHECI@discussions.microsoft.com> wrote in message news:ACA60D76-E791-4A1E-A016-834F59FAB434@microsoft.com...
>I have a series of 200 files with file names in the format 00000### where ###
> is a 3-digit number. I'd like to find an easy way to truncate the leading
> zeros so that the file name is just ###. I need to preserve the actual
> number as opposed to issuing a new series of sequential numbers. Any ideas?
> Thanks!

In a batch file called, say "trimmer.bat", add the following lines inside it, and then execute it entering "cmd /v /c <path>trimmer" in a DOS shell after you have navigated to the directory with your files (the /v switch is required to force immediate expansion of environment variables within the for-loop). The <path> isn't needed if you save trimmer.bat in a directory listed in your PATH environment variable. I added D:\Batch to my PATH and that's where I save by .bat files.

File: trimmer.bat
--------------------

@echo off

rem --- MAIN

for %%a in (*) do (
set origname=%%a
set modname=!origname!
call :LeftTrim 0
echo Old name = "!origname!"
echo New name = "!modname!"
ren "!origname!" "!modname!"
echo.
)
goto :EOF

rem --- FUNCTIONS

:LeftTrim
rem - Deletes specified leading prefix character(s), plus any leading space(s)
rem - after the delete. If prefix character omitted, delete leading spaces.
rem - Syntax: call :LeftTrim [char]
rem (uses global variable "modname" )
if "%1" == "" goto DelSpace
rem - Use only the first character of the input parameter.
set delchar=%1
set delchar=!delchar:~0,1!
rem - Remove the prefix character(s).
:DelPrefix
if "!modname:~0,1!" == "!delchar!" (
set modname=!modname:~1!
goto DelPrefix
)
rem - Remove any [resultant] leading spaces.
:DelSpace
if "!modname:~0,1!" == " " (
set modname=!modname:~1!
goto DelSpace
)
set delchar=
goto :EOF

Reply to Anonymous
Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > Truncate file names?
Go to:

There are 1268 identified and unidentified users. To see the list of identified users, Click here.

Please mind

You are about to answer a thread that has been inactive for more than 6 months.
If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.

Add a reply Cancel
Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them