Solved Batch- cut and Paste FOLDERS listed in txt file

September 12, 2012 at 06:14:03
Specs: Windows XP
Hi all,
I have a notepad file with a list of folder names. what i need is a batch file that will read from the text file and cut the folders (with subfolders and files) and paste it to a different directory.

The txt file will have the names of the folders listed.

for example

Folders are located here: C:\source
Folders should be copied here: C:\destination
Which folders exactly needs to be copied stands in the txt.

Thanks,


See More: Batch- cut and Paste FOLDERS listed in txt file

Report •


✔ Best Answer
September 12, 2012 at 17:37:45
here's one way, based on the first script:
@echo off
for /f %%a in (copyjob.txt) do (
xcopy /e /i c:\source\"%%a" c:\destination\"%%a"
:: i don't think the following is required, but ya never know.
:: del /s c\source\"%%a"\*.*
rd /s /q c:\source\"%%a"
)
::==== end

and here's another approach, based on Tony's and Mike's excellent suggestions (which i did not think of):
@for /f %%a in (copyjob.txt) do move c:\source\"%%a" c:\destination\"%%a"
:: end



#1
September 12, 2012 at 07:40:43
nbrane already gave you a working solution.

Link

Tony


Report •

#2
September 12, 2012 at 07:49:41
Hi Tony,
he gave me a working solution for my other post, yes.
But this is another question.
My first post is regarding copy paste.
What I need now is cut paste.
I think I can't just change "xcopy" to "xcut" or "xmove" inside the Batch.

Report •

#3
September 12, 2012 at 07:55:31
I think the issue is that he is looking for a removal of the origional files once the copy
has been completed.

I believe adding this to the end should accomplish this

&& del c:\source\"%%a"

once its figured out you could add a /Q switch.

probably recommend testing though.

your other option might be to use the

move command

:: mike


Report •

Related Solutions

#4
September 12, 2012 at 09:16:22
Hi mikelinus,
Thanks for your response.

&& del c:\source\"%%a" is deleting only the files which are stored in the folder,
I need the complete Folder deleted (not only the files in it)


Report •

#5
September 12, 2012 at 10:39:03
rd c:\source

note will only delete if empty

:: mike


Report •

#6
September 12, 2012 at 11:08:21
Why not just use move instead of copy and delete?

Tony


Report •

#7
September 12, 2012 at 11:55:09
I agree, mentioned that in post number 3 as well. :D sometimes its easier.

:: mike


Report •

#8
September 12, 2012 at 17:37:45
✔ Best Answer
here's one way, based on the first script:
@echo off
for /f %%a in (copyjob.txt) do (
xcopy /e /i c:\source\"%%a" c:\destination\"%%a"
:: i don't think the following is required, but ya never know.
:: del /s c\source\"%%a"\*.*
rd /s /q c:\source\"%%a"
)
::==== end

and here's another approach, based on Tony's and Mike's excellent suggestions (which i did not think of):
@for /f %%a in (copyjob.txt) do move c:\source\"%%a" c:\destination\"%%a"
:: end


Report •

#9
September 13, 2012 at 09:03:28
Hi Guys,
thank you all for your replies.
All of your repliers where very helpfull, (just voted nbranes answer as best since it was complete)

thanks again!!!


Report •

Ask Question