tonelm54
asked on
Years with spaces
Not sure if this is the right zone, apoligise if it isnt.
Ive written a quick batch file to backup some mysql databases, but put the date at the end of the file, so Ive got:-
The backup works great but the filename is c:\Backups\myDB_2011 -09-02.sql
On a quick look the value Year is "2011 ".
Is there anyway to trim the spaces from the value?
Thank you
Ive written a quick batch file to backup some mysql databases, but put the date at the end of the file, so Ive got:-
@For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @(
Set Day=%%A
Set Month=%%B
Set Year=%%C
)
g:\xampplite\mysql\bin\mysqldump -h 192.168.1.105 -u myUser -pmyPass myDB >"c:\Backups\myDB_%Year%-%Month%-%Day%.sql"
The backup works great but the filename is c:\Backups\myDB_2011 -09-02.sql
On a quick look the value Year is "2011 ".
Is there anyway to trim the spaces from the value?
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And just to add on slightly. one way to avoid this problem that BAT scripts can suffer from is to use quotes around the set, so that even if there are trailing blanks they won't be assigned to the variable, like:
Set "Day=%%A"
Set "Month=%%B"
Set "Year=%%C"
~bp
ASKER