You can replace a character in an Environment Variable using the following syntax:
set VariableName=%VariableName:<ReplaceCharacter>=<ReplacementCharacter>%
If you want to rename a file from filename
for /f "tokens=1,2,3,4* delims=/ " %%i in ('date /t') do set JSIUsrDT=%UserName%
Note:There is a space after the : in the set JSIUsrDT=%JSIUsrDT: =_% statement.
See tip 494 for the %~dp1 syntax.
the following batch file would work for a USA locale: ( call JSIUsrDT <Drive:>\Directory\filename.ext)
set JSIUsrDT=%JSIUsrDT: =_%
pushd %~dp1
rename %1 %JSIUsrDT%
popd
0 comments
Hide comments