# Batch/Script for adding prefix to filename



## lanky71 (Jun 9, 2012)

Hi,
I am running watchdirectory and for different process's I require the file to have "two" names...

One set of files simply backups to ftp server unrenamed (currently working perfectly)
The second set of same files I require to copy to a subdirectory and add a prefix to of "bckup"
eg: bckup.filename.rar

So I have done some reading and apparently its a DOS based batch/script of vbs maybe?

Also... if it is going to work better to have the copy/rename process in one process then if you can advise that as well.

Thanks in advance.


----------



## Squashman (Apr 4, 2003)

Show me what you got so far.


----------



## lanky71 (Jun 9, 2012)

Hi,
I haven't got anything as I don't know about batch files or scripts.
That's the reason I use watch directory as its like a wysiwyg program.


----------



## Squashman (Apr 4, 2003)

Well you are not giving me much detail to go off of so this may be a waste of my time.

```
set source=C:\watch
set dest=C:\backup
pushd "%source%"
FOR /F "tokens=* delims=" %%G in ('dir /a-d /b') DO COPY /Y "%%G" "%dest%\bckup.%%G"
popd
```


----------



## lanky71 (Jun 9, 2012)

Hi, thank u for the reply I will edit destinations and give it a try.
Sorry I didn't know what information you needed.
Thank u for the code and if I have any issues I'll let u know.

Thank you again!


----------

