1.

Solve : Help Needed with document copy and rename?

Answer»

Hello to everyone

I'm new to DOS and i need some help with something that i have to do. I'll try to give as much detail as i can.

I have a folder(let's name it folder1) with several subfolders that include many documents(more than 4500) of 4 different types: excel(.xls & .xlsx), word( .doc % .docx), powerpoint(.ppt & .pptx) and pdfs.

I need to make a copy(let's name it folder2) of this big folder(folder1) but i have to replace the documents with blank ones but with the same title.

I thought that what i should do is to create blank documents of those types, and then make a batch file that will create the folders and the subfolders that exist at folder1, and then check the documents that exist there, copy the blank document from where i saved it and paste it in the new made folder in folder2 and give the name that this document had in folder1.

But i'm confused on how to use the dos commands to do all those commands with that sequence.

Can someone please help me with this?
Thanks in advanceMake sure that the source and destination formats are as shown, with trailing slash/and wildcards.

Code: [Select]@echo off
SET "source=c:\folder1\*.*"
set "dest=c:\folder2\"

xcopy "%source%" "%dest%" /t/e
for /f "tokens=2 delims=>" %%a in ('xcopy "%source%" "%dest%" /s/h/e/k/f/c/l') do (
for /f "tokens=*" %%b in ("%%a") do type nul >"%%b"
)
pauseThank you for your fast reply. I tried your code but there was an error(my OS is at greek and i'm not sure what is the proper translation in english but the message if i'm translating corectly is that "Cannot perform a cyclic copy" typed two times and then it prompts me to press any button to continue and when i do it it shuts down.
Let me give you some extra information.
My source folder is C:\Users\DM\Dropbox(what i named folder1) and that my destination folder is C:\Users\DM\Desktop\drop2.
(in case it is needed i made a blank document of each type of documents that are contained in folder1 in C:\Users\DM\Desktop\blank)

I changed in the code you gave me LIKE that

Code: [Select]@echo off
set "source=C:\Users\DM\Dropbox*.*"
set "dest=C:\Users\DM\Desktop\drop2"

xcopy "%source%" "%dest%" /t/e
for /f "tokens=2 delims=>" %%a in ('xcopy "%source%" "%dest%" /s/h/e/k/f/c/l') do (
for /f "tokens=*" %%b in ("%%a") do type nul >"%%b"
)
pauseDo i have to do something else?
Also this code will also create the subfolders that exist in folder1?
Again thank you very muchChange this line
set "source=C:\Users\DM\Dropbox*.*"

to this
set "source=C:\Users\DM\Dropbox\*.*"

It will create the folder structure, and a set of zero byte files with the name of the original documents.It works now, thank you very much. You just saved me from a lot of hours.
I wish you the best.

PS: Except the thanks button bellow, is there any other way to give you some "CREDITS" here?I'm pleased to hear it helps you - that's the best kind of feedback we can get.

The thanks button is used by the observant and interested people.Sorry if i'm being annoying.
Again i'm trying to translate from greek the "warnings" on cmd.
It types 2 times "memory is not enough"
Then 9 times "The system cannot LOCATE the disk(or drive) path specified" (it's one of the two drive/disk i think.)
Then 5 times "File name syntax, directory or volume label is incorect"

I tried to change some of the commands on your code with no luck, and after reading a while i'm not sure if the problem is because the number of characters that cmd can process is limited or something else. I'm SAYING that because there are some documents that i want to copy that are as "deep" as on the 7th or 8th subfolder (and some of them have big names)

The code is working but of a total of 9186 documents it is copying 1586
Thanks againI have to add that i checked and found that it stacks on an htm file that has the "<>" on its name.Quote from: jimakos05 on December 23, 2013, 08:05:29 AM

I have to add that i checked and found that it stacks on an htm file that has the "<>" on its name.

They are illegal filename characters in Windows - but there are similar looking ones in Unicode.

Unicode and foreign language characters are often problematic in batch files. You have to use the right
code page with non-English characters, using the CP command in the beginning of the batch file, and
if it is Unicode then that will fail in many ways with batch code. VB Script is a better choice there.

It's also possible that your path\filename length is too long for some of them too.


Discussion

No Comment Found