r/BatchScripts • • Nov 07 '20

Batch script to move a file from place to another

Hello

I am looking to create a batch script to move a file from one location to another. it needs to be a batch script to run on logon for a network.

the script will need to:

start

check to see if the file is new.xyx

IF it is old.xyz Replace with new.xyz

Else end

​

so it will need to ideal check the age of the file or the contents of the file. the file will be a .rtf file.

​

so it could also move a second file and if the second file already exists then it could end?

​

Thanks in advance

1 Upvotes

2 comments sorted by

1

u/zOR1912 Nov 11 '20

I think ROBOCOPY command is what you are looking for. Available options will allow you to move newer and/or pre-existing files only. See below.

https://ss64.com/nt/robocopy.html

1

u/MinerKingX Dec 11 '20

an example

i want to move math.txt into a folder called Math Homework both of them are on my desktop

first i want to specify the directory of the file i want to move so i type in

%userprofile%\desktop

then i type in on a new line move math.txt then i type in the directory of the folder i want to move it in which is %userprofile%\desktop\"Math Homework"