I need to get a file path relative to files with the bat.
Folder structure
file.bat - folder1 - subfolder1 ----- abc.image ----- def.image - subfolder 2 ---- more . Image - Folder 2 - Subfolder 1 ---- Bhimize .image - subfolder2
For abc.image, I want to get the name of the folder (such as folder 1) and the combination folder + Subfolder (Folder 1 / Subfolder 1 on here)
I looked at this post: but I can not work for it. The output is giving me a lot of chaos.
I finally want to do this:
set "prefix = td" set "file = list_of_images.xml" echo ^ gt; & gt;% file%) echo ^ < / Files ^ & gt; & Gt; & Gt; Thanks for the help and suggestions!
% file% "Lang-dos prettyprint-override"> For / f "tokens = 1, * delims = \" %% a in ('xcopy'. *. * Image ""% temp% "/ s / e / l ') if not" %% b The easiest way to get a list of files with relative path is to xcopy You can use "virtual" You can also use the subst
command to create the drive. The drive letter with the root of the drive pointing to the drive start, and then refer to this code and Use the same code, which will no longer retrieve the top folder structure
Edit for comments for optimization
for / f" tokens = 2-4 delims = \ "%% a in ('xcopy'. * * Image" "% temp%" / s / e / l ') do Echo folder = %% output from a subfolder = %% b file = %% c
format xcopy
is in the format
. Folder \ subfolder \ file
Then, using backslash as delimiter, we skip the first token and retrieve the second (folder), the third (subfolder) And the fourth (file)
No comments:
Post a Comment