Batch Programming - Not deleting partial files being written - file

I am trying to develop a batch script which copies a list of files from the a source directory to another directory and does some functions. Once the copy has been done, the files needs to be deleted from the source directory.
In the source directory, we are receiving files on real time basis 24x7 from an external source.
How can I make sure, the copy or the delete from the script does not impact any files which are currently being sent (incomplete files which are in relay at that moment) from the external source in the source directory, whilst the script is doing its own job?
The script needs to be ran every 5 minutes.
Due to some challenges, we cannot xxcopy for our functionality.
Please can you advise.

Instead of COPY& DELETE use MOVE, so the batch fragment would look like this:
FOR %%F IN (C:\SOURCE\*.*) DO MOVE %%F C:\TARGET\
If file in incomplete (other process uses it), then MOVE on that file will fail. Next time the script is run, it will attempt to move that file again.

Related

Efficiently Download Newer files via FTP (Large amount of files with WinSCP commandline)

I am currently creating a small process that will download any new or updated file from an FTP(not SFTP) location to a local drive. I have written a small batch script along with WinSCP, but it takes FAR too long. There are around 200k files and 16k folders on the FTP. It takes just under an hour to check every file and folder, not including any time downloading any new/updated file. From what I understand, WinSCP compared file modification dates of every single file and folder, which is why it takes so long. I'm not sure where to go from here.
I am using WINDOWS 10.
Is there a better way to go about synchronizing these? Possibly check FTP drive if anything has been changed, if so, find the change and download it? Will post pics of batch if needed.
Thank you!

Sync folders with xcopy/batch based on checksum?

I'm trying to make a simple batch for windows that will basically sync two folders, the catch is that the files in the folders can be named arbitrarily and the snyc should be based on the checksum. I've only found information about xcopy that compares the timestamp so I'm wondering if this is possible in a simple matter at all.
Here is the scenario I'm trying to manage, you've got the "Import Folder" containing the files named A_2.bmp and A_3.bmp and the "Target Folder" containing file A_1.bmp.
File A_2.bmp is infact the same file as A_1.bmp, just with a different name and thus should be skipped, A_3.bmp should then be copied over to target folder and icrementally renamed to A_2.bmp.
This probably sounds more like a work for patching software, but I'm looking for a solution that doesn't require building patches all the time and is open for the user (so he can just drop files into the import folder and run it whenever the need arises)
If there is software for such a thing that is free and can be distributed without installing I would also consider this a good option, but I haven't found anything.
I'm thankful for any advice and help on this matter so thank you very much for your time and help!
You have this command line utility :
http://www.microsoft.com/en-us/download/details.aspx?id=11533
You can then make a bat who simply test the checksum of the files

Copy files automatically from usb to specific folder with specific extensions

I have huge amount of flash drives and I need to backup my files on specific folder (for example C:\Backup).
There are two problems :
1. I need to backup files with .doc and .docx extension only.
2. When flash drive is inserted, I want that files would copy automatically.
(It's loop if I remember)
Is there any batch solution for this?
try this tutorial for autoplay USB
Then, i am thinking, instead of the autoplay.exe you can set it to run a batch file instead.
In that batch file use the xcopy command.

Need to write a batch file job

I need to write a batch job file to keep two folder in sync.
Inputs : Source and Destination folder names.
senario :
If the destination folder/subfolder is not found – create and proceed
If the files are already present in both the folders Compare and overwrite destination file if timestamp/size differs.
If the file not present in source and present in destination, delete the destination file.
kindly help me to write the batch job.
Thanks Vikram
A batch file written by a self-professed inexperienced user - even run periodically - is not a good replacement for a sync tool like rsync or dropbox or even the Briefcase built into Windows. Robocopy looks a good bet.

batch script to find a particular folder in a drive

am a newbie to the batch script, i have many folders called LIB in my drive
say it can be as LIB_data,lib,lib_ac anything that starts with lib or LIB... i want to list all these directories and sort them in which they have created in the pc and copy the latest directory contents to BATCH_LATEST_LIB_FILES folder,that will be a new folder created by this batch file.i want this new folder to be created in the path where this batch file is present. please help me with a batch script.
You might look at FOR, DATE, TIME, SORT, IF, GOTO and XCOPY.
This site is a great resource for batch files.

Resources