Computing.Net > Forums > Disk Operating System > DOS rename command (Win XP)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

DOS rename command (Win XP)

Reply to Message Icon

Name: Valiant
Date: July 19, 2009 at 05:24:56 Pacific
OS: Windows XP
Subcategory: General
Comment:

(1) I have 0,000s of digital pictures grouped in folders. I would like to append the date snapped to the front of the filename in the format in [ YYYYMMDD <sp> filename.ext ] format. (2) I would then like to remove any characters before the picture sequence so the filename would read [ YYYYMMDD nnnn.ext ]. (3) Typical filenames I would like to change would be IMG_3036.jpg, IMG_3037.jpg renamed to 20090621 3036.jpg, 20090621 3037.jpg.



Sponsored Link
Ads by Google

Response Number 1
Name: DAVEINCAPS
Date: July 19, 2009 at 13:35:55 Pacific

Response Number 2
Name: jefro
Date: July 23, 2009 at 18:32:38 Pacific
Reply:

I think you'd be better off taking the files you wish and put them in a file by name and date. Then use rename and for next to use list to perform. Be sure to be in correct path.

like

dir > file.txt (use options to get your date format if you can otherwise need one more step)

Then for 1 to what ever do rename until end.

There are plenty of ways to write batch files.

"Best Practices", Event viewer, host file, perfmon, antivirus, anti-spyware, Live CD's, backups, are in my top 10


0

Response Number 3
Name: ghostdog
Date: July 25, 2009 at 07:21:57 Pacific
Reply:

here's a vbscript you can use

Set objFS = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
Set objFolder = objFS.GetFolder(strFolder)
today=Now
strYear=Year(Today)
strMth=Month(Today)
strDay=Day(Today)
If Len(strMth) = 1 Then
	strMth="0"&strMth
End If 
If Len(strDay) = 1 Then
	strDay="0"&strDay
End If 
strDate = strYear & strMth & strDay
For Each strFile In objFolder.Files
	strFileName = strFile.Name
	If InStr(strFileName,"IMG_") > 0 Then
		strFile.Name = Replace(strFileName,"IMG_", strDate & " ")
	End If 
Next

save as myrename.vbs and on command line

c:\test> cscript /nologo myrename.vbs

GNU win32 packages | Gawk


0

Response Number 4
Name: ricardo647
Date: August 9, 2009 at 22:47:37 Pacific
Reply:

I made an alternative solution using a bat (nt script).
Save the code (below) with a .bat entension. Ex: convert.bat
And run it. I have already tested and it worked fine.

@echo off
setLocal EnableDelayedExpansion
for /f "tokens=1-4 delims=/ " %%d in ('date /t') do set dat=%%g%%f%%e
for %%a in (*.jpg) do call :subst "%%a"
goto end
:subst
for %%a in (%1) do (
set y=%%a
set y=!y:~1,4!
if !y!==IMG_ (
set x=%%a
set x=!x:IMG_=-!
set x="!dat!!x!"
rename %%a !x!
)
)
:end


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: DOS rename command (Win XP)

DOS and Win XP Pro www.computing.net/answers/dos/dos-and-win-xp-pro/15053.html

running dos programs in win xp www.computing.net/answers/dos/running-dos-programs-in-win-xp/9114.html

DOS restore command & WinXP www.computing.net/answers/dos/dos-restore-command-amp-winxp/15647.html