How does someone do a batch rename via the command line without altering the file, except its name? That is, how do you do the rename without doing a conversion? Is it possible?
Announcement
Collapse
No announcement yet.
Batch Rename via Command Line
Collapse
X
-
I don't see any reason why renaming should be converting your files.
See Batch Renaming
There are three options on the dialogue: Convert, Rename, or Both.Before you post ... Edit your profile • IrfanView 4.62 • Windows 10 Home 19045.2486
Irfan Paint • Irfan View Help • IrfanPaint Help • Riot.dll • More Skins • FastStone Capture • Uploads
Comment
-
Originally posted by Bhikkhu Pesala View PostI don't see any reason why renaming should be converting your files.
There are three options on the dialogue: Convert, Rename, or Both.
Comment
-
Hi Skippybox,
Why do you want to use IrfanView ? The DOS "rename" command could do that.
LaurentBefore you post ... fill in your OS and IV version in your profile.
Comment
-
Originally posted by Laurent View PostWhy do you want to use IrfanView ? The DOS "rename" command could do that.
The DOS 'rename' command does not allow you to specify a new path for the file. Is the Batch dialog the only way in IrfanView? I would like to do it without an interface, so I could turn it into a shortcut. Is a batch file better. Any ideas?Last edited by Skippybox; 09.09.2008, 09:36 PM.
Comment
-
Hi Skippybox,
Then use the move command.
LaurentBefore you post ... fill in your OS and IV version in your profile.
Comment
-
Hi Skippybox,
this is possible, with a few restrictions:
if you have german umlauts or special characters like "&" or "+" in the filename, than windows can deal with them, a DOS script not (ok, a DOS script can work with the german umlaut but you can not convert it easy from the Windows character set to the DOS character set).
What do you exactly need? A script which you can put in the send to folder and you want to send an folder to this script. The script shall move, copy or rename the files to another given or asked name?
Maybe I can help you.
Regards, Nils.
Comment
-
Originally posted by derniwi View PostWhat do you exactly need? A script which you can put in the send to folder and you want to send an folder to this script. The script shall move, copy or rename the files to another given or asked name?
I probably should use a renamer program, but I would like to experiment with scripting. I was basically looking for a quick way using a shortcut to re-pad a folder of files to make sorting easier. I would like a script similar to what you described. I know you are quite talented at batch files. Perhaps you could give me some pointers or share your ideas with me? I would love to learn!
Comment
-
Hi Skippy,
so take a look at this script. But use it with care! I have done just a few little tests...
Code:@echo off rem ask for values? set askfor=y rem set default values set defdestpath=D:\renamed set defpattern=*.jpg set defcopymove=c set defprefix=My_picture_ set defpostfix=_fun set /a defstartnum=1 rem the source path is passed from the send to function set sourcepath=%~1 rem allow the output path to be dragged and dropped to the dos box if "%askfor%" == "y" set /p destpath=Rename to path [%defdestpath%]: if "%destpath%" == "" set destpath=%defdestpath% rem ask for file pattern if "%askfor%" == "y" set /p pattern=File pattern [%defpattern%]: if "%pattern%" == "" set pattern=%defpattern% rem ask for copying or moving if "%askfor%" == "y" set /p copymove=Copy or Move [%defcopymove%]: if "%copymove%" == "" set copymove=%defcopymove% rem check if the files should be copied or moved set copymove=%copymove:~0,1% if /i "%copymove%" == "m" set copymove=move if /i "%copymove%" neq "move" set copymove=copy rem ask for file name prefix if "%askfor%" == "y" set /p prefix=File prefix [%defprefix%]: if "%prefix%" == "" set prefix=%defprefix% rem ask for file name postfix if "%askfor%" == "y" set /p postfix=File postfix [%defpostfix%]: if "%postfix%" == "" set postfix=%defpostfix% rem ask for starting number if "%askfor%" == "y" set /p startnum=Starting number [%defstartnum%]: if "%startnum%" == "" set startnum=%defstartnum% set /a startnum=%startnum% rem check for files if not exist "%sourcepath%\%pattern%" goto NoFiles rem check if outpath contains a drive letter set drive=%destpath:~0,2% set drive=%drive:~1,1% if "%drive%" neq ":" set destpath=%sourcepath%\%destpath% rem check if the output path exist if not exist "%destpath%\." md "%destpath%" for /f "delims=" %%a in ('dir /b /a-d /on "%sourcepath%\%pattern%"') do call :rename "%sourcepath%\%%a" goto end rem Move the files :rename set suffix=%~X1 set number=0000%startnum% set number=%number:~-4% set filename=%prefix%%number%%postfix%%suffix% %copymove% %1 "%destpath%\%filename%" set /a startnum=startnum + 1 goto :eof rem Write some text if no files are found :NoFiles echo Sorry, but I can't find files matching "%pattern%" in the echo directory "%sourcepath%". goto end :end pause
Comment
Comment