| 1. |
Solve : xcopy for specific files and their folders? |
|
Answer» Greetings. After I perform a subset, I will be able to pull out all the paths of the files I need from the database, format them as needed and paste them into a txt file, thus my attempts at using the .xcf files with xcopy.then CONSIDER it done because you already have the list of file path in a file. now need a little bit more information: 1. is this file path is full-path-name or relative-path-name? 2. would you mind to post couple of lines from the xcf file. i am thinking to do it in a simple for loop and light-weight copy function.Thank you Reno. You give me hope. I just spent another couple hours looking for solutions and it may involve setting parameters in a batch file, but again, I'm not fully understanding what I'm seeing. So far, I've been using full-path-names, as that is how I've been able to successfully copy files across the network. Below is a sampling of the files I need to copy and create the directory structure for. As you can see, there are a variety of directories and only a few files from each. "T:\! Field_Verification_Data\BW\Big Walnut27\50.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\48.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\87.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\58.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\62.jpg" "T:\! Field_Verification_Data\BW\Big Walnut101\90.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\70.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\73.jpg" "T:\! Field_Verification_Data\BW\Big Walnut101\70.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\80.jpg" "T:\! Field_Verification_Data\BW\Big Walnut100\55.jpg" "T:\! Field_Verification_Data\BW\Big Walnut100\38.jpg" "T:\! Field_Verification_Data\BW\Big Walnut56\68.jpg" c:\pics /oAlog/h/c/e/r/y I don't mind concatenating what is needed to each entry to allow this to work, so I look forward to your suggestions. f.y.i. I'm including a bit of coding I found that may be something to consider as well, but I'll await your suggestions. echo off for /F "tokens=*" %%* in (c:\Files.txt) do xcopy /y /c /d /h "%%*" d:\Target\ Quote from: garv on May 28, 2009, 09:41:47 AM "T:\! Field_Verification_Data\BW\Big Walnut27\50.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\48.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\87.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\58.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\62.jpg" "T:\! Field_Verification_Data\BW\Big Walnut101\90.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\70.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\73.jpg" "T:\! Field_Verification_Data\BW\Big Walnut101\70.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\80.jpg" "T:\! Field_Verification_Data\BW\Big Walnut100\55.jpg" "T:\! Field_Verification_Data\BW\Big Walnut100\38.jpg" "T:\! Field_Verification_Data\BW\Big Walnut56\68.jpg" c:\pics /oAlog/h/c/e/r/ybefore i write something up, need to confirm a few things: is it no line-break between each entry? or the formatting is loss due to copy&paste from unix system maybe?? what is this last line mean - c:\pics /oAlog/h/c/e/r/y? there is a limit in cmd a certain number of characters in a variable. if you able to format the file like this: Code: [Select]"T:\! Field_Verification_Data\BW\Big Walnut27\50.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\48.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\87.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\58.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\62.jpg"then a batch code would be possible, otherwise i need to do it in another scripting language, such as vbscriptCorrect, what I pasted has no line-breaks between entries, however if I need line breaks (or commas, tabs etc.), I can make it that way. The last line is what I was using as the destination directory (this can be anything), and the remainder were xcopy switches including the creation of a log file for errors, which I have found helpful in the past.for this text format with line break, support unlimited number of entry: destination directory is at the top for performance sake, if you put the destination directory on the last line, it will take a long time for large list Code: [Select]c:\pics "T:\! Field_Verification_Data\BW\Big Walnut27\50.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\48.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\87.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\58.jpg" "T:\! Field_Verification_Data\BW\Big Walnut27\62.jpg"the batch code: Code: [Select]echo off & setlocal set /p dest=<test.txt if %dest:~-1%.==\. set dest=%dest:~0,-1% for /f "skip=1 tokens=*" %%a in (test.txt) do ( if not exist "%dest%%%~pa" MD "%dest%%%~pa" && echo created "%dest%%%~pa" echo copying "%%~a" copy "%%~a" "%dest%%%~pa" )Reno, FANTASTIC. I tested what you posted and it worked, then I chose a more complex set of paths and files and it worked perfectly. That is exactly what I'm in need of. Rest assured it will be put to good use. If it is ok with you I will make this available to other people that have had the same issue that I was dealing with; there are many. If you'd like to receive some feedback or credits for this I know a place we can probably post it. Let me know your thoughts. In the mean time I will spend some more time deciphering what you created and test it in some different ways. Once again. Fantastic. Thank You.glad it works well. feel free to modify and give it to your friends, just dont put my name on it, i'll be ashamed if my name tagged somewhere for such a simple script. if the simple script help you out somehow, you only need to click "thanks at post #11". that's more than enough btw, click once only, i don't like cheating Reno, I clicked the thank you button 'once' for you yesterday right after I tested the script. If I can do what I'd like to with the script I will give you an update, it really could help a lot of people. Have a good weekend. - joshReno, I'd like to join in on the thank you's here!! In researching the very issue and need over the past two days (and many experiments later), I came across this thread and was able to IMPLEMENT your .bat in the exact MANNER I needed. Best regards, L. Burr |
|