Remove leading characters and pass to new variable
Posted: 20 Jan 2011 14:36
Hi All,
I have a log listing fully qualified file names that need to be copied.
ie.
\\some.server.domain.ca\c$\storage\folder\with\stuff\init.jpg
\\some.server.domain.ca\c$\storage\folder\with\stuff\more.jpg
\\some.server.domain.ca\c$\storage\folder\with\stuff\again.tif
the bit of code I'm fighting with is this
setlocal enabledelayedexpansion
(for /f "tokens=*" %%a in (!dest2!output.log) do (
set filenames=%%a
set spath=!filenames:~73,0!
xcopy !filenames! !dest2!!spath! /f /h
))
it should, take the fully qualified names and load them into !filenames! to be the source for xcopy, and also remove 73 characters from the front of each line, so xcopy can create the same directory structure in the destination. (those 73 characters are \\some.server..... which i don't need. )
I can't tell if anything is being loaded into !spath! the echo output just shows !spath! rather than the data (if any) in it.
- Kip
I have a log listing fully qualified file names that need to be copied.
ie.
\\some.server.domain.ca\c$\storage\folder\with\stuff\init.jpg
\\some.server.domain.ca\c$\storage\folder\with\stuff\more.jpg
\\some.server.domain.ca\c$\storage\folder\with\stuff\again.tif
the bit of code I'm fighting with is this
setlocal enabledelayedexpansion
(for /f "tokens=*" %%a in (!dest2!output.log) do (
set filenames=%%a
set spath=!filenames:~73,0!
xcopy !filenames! !dest2!!spath! /f /h
))
it should, take the fully qualified names and load them into !filenames! to be the source for xcopy, and also remove 73 characters from the front of each line, so xcopy can create the same directory structure in the destination. (those 73 characters are \\some.server..... which i don't need. )
I can't tell if anything is being loaded into !spath! the echo output just shows !spath! rather than the data (if any) in it.
- Kip