Re: The killer space!
- From: "Todd Vargo" <tlvargo@xxxxxxxxxxxxxx>
- Date: Sat, 16 Feb 2008 02:38:31 -0500
sand wrote:
A friend created a .bat file for me so I could easily rename files I
download from a photo site. The site names each file: Picture_1.jpg
and I want to rename them to follow a date-roll-shot number:
2008-02-15-01-01.
So here's the script:
------
::BatchRename.cmd
@echo off
for /f %%i in ('dir /b') do call :rename %%i
goto :EOF
:rename
set Oldname=%1
set NewName=%oldname:Picture_=2006-08-16-03-%
rename %oldName% %newname%
goto :EOF
------
Then the photo site changed the way they named the individual files.
So instead of "Picture_1.jpg" there is now a space instead of the
underline so it reads "Picture 1.jpg".
And the script doesn't work anymore.
Could some one help me update the .bat file so it can handle the empty
space?
::BatchRename.cmd
@echo off
for /f %%i in ('dir /b') do call :rename "%%i"
goto :EOF
:rename
set NewName=%~n1
set NewName=0%NewName:Picture =%
set NewName=%NewName:~-2%
rename %1 2006-08-16-03-%newname%%~x1
goto :EOF
.
- Follow-Ups:
- Re: The killer space!
- From: Tom Lavedas
- Re: The killer space!
- References:
- The killer space!
- From: sand
- The killer space!
- Prev by Date: The killer space!
- Next by Date: variable in RegEx
- Previous by thread: The killer space!
- Next by thread: Re: The killer space!
- Index(es):
Relevant Pages
|