for loop - FOR /F processing of CSV with differing number of variables -
I am trying to write batch scripts to move thousands of folders from my current location to a new location. I have a CSV with original / new location information such as:
[full path of current location], new_dir_1, new_subiere_2, [new_subdir_3], [etc],
Last time I have achieved good fortune using FOR / F, and that is what I am trying to do here.
for / f "tokens = 1-4 delims =,"% g in (text_file.cnc) do xcopy "%% g" "d: \ %% h \ %% i \ %% j "/ e / i / y
fails where there are not enough tokens for the variable and I get two follow-up backslashes in my destination path.
for / f "tokens = * ....
Failed too - I understand that" tokens = * "differ from each image But maybe I will have this wrong? It seems that the whole line is to be taken as a token.
Is there any way to modify your "DO" order only Only make the destination path intensive (i.e., if new_subdir_3 does not exist, then the path should be "d: \ new_dir1 \ new_subdir_2 \" and "d: \ new_dir1 \ new_subdir_2 \")?
Thank you. This Emprop = "text">
is an easy way to solve your problem. To control the problematic path for just use a special token = *
or token = 1, *
*
loop for
loop for
/ f "tokens = 1-4 delims =," What to do %% g (text_file.csv) (%% ("D: \ %% ~ h \ %% ~ i \ %% ~ J") What's the "%% ~ g" %% ~ FA "/ E / i / y)
%% ~ fa
D: \ %% ~ h \ %% ~ i \ %% ~ The complete path generated will return. J \.
, but all double backslashes will be deleted in the process.
Comments
Post a Comment