I want to copy file from one folder to another using cmd, with each file copied is updated with newer date - cmd

I want to copy from one folder to another on daily basis but each file copied is updated with current date.
I know the code to copy file but I dont know how to copy file with updated date and I need to put this in Task scheduler to run it daily.
This is my code:
cd C:\Automation\
Copy "Z:\VENDOR_LOAD\Access DB\COMPLETE SM DATA\SupplierMaster_Query.xlsx" "Z:\VENDOR_LOAD\Access DB\COMPLETE SM DATA\BACKUP\SupplierMaster_Query_.xlsx"

Related

Move file already open by the script

I will create a python script to download some pdf files from a web site and next save these files in some directories according to data extracted by each pdf. The problem is: I must open a pdf file in my script in ordert to extract data (I use pdfquery) but when I try to move the file to destination directory I get an error: the file is open by another process. I supposse the proces is the script. My qyestion is, it's possible to release the file from the python script and finally move it to the destination without errors?
A solution is copy (instead move) file and delete it manually or create another script which move the files when the "download and extract" script finish is job. But I search a clean approach.

Using NDM run options to move a files that contact a date and time stamp but keep the same name

I have a process that will produces a file with the current date and time stamp. I need to archive this file so I have backup if there is a problem. Currently I have to rename the file manually in order for the current move command process in NDM to move the file to a processed directory. this is done as another way to tell if the file did process. I want to change the transfer to use a wildcard so I don't have to change the file name each time. I can I get the move command to use a wildcard to find this file and move out so another file can be process. I have the batch file that will archive the file and add a new date and time stamp. I just to get this part worked out.

How to copy and rename file in CMD script with a date/version number appended to it

I have a CMD script that currently copies file from one location to another. It overwrites the old file with that name in the destination source which is fine. Now, I would like to keep historic data available in the Archive (separate csvs with different names). I am trying to copy the existing file to the archive before the file is updated with new data. What I thought is to create Archive folder and copy original file to it. However, with the setup I have now, it will be erasing the older version of the file because they would get the same name applied.
I tried adding DAT variable which is a current date and append this in the beginning of the file name but it prompted a syntax error. Not sure if this is even possible in CMD. I would really appreciate some assistance. If you take DAT out of the code, it will work and copy the file fine but the next time I run this script, it will overwrite the file while I want to have different historic files with name containing a date with identifier. If appending date is not possible, perhaps we could create version number by ourselves starting from 1.
Here is the code that I tried:
#ECHO OFF
set day=%date:~0,2%
set month=%date:~3,2%
set year=%date:~6%
SET DAT=%DATE:~6%%DATE:~3,2%
Set ZEIT=%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
copy /Y \\srvditz1\DataXchange_R3\TUS_EXCHANGE\TUS300_digi_SFM\30_Visualization\ZPP00138_TUS350.csv \\srvditz1\DataXchange_R3\TUS_EXCHANGE\TUS300_digi_SFM\30_Visualization\Archive\%DAT%_ZPP00138_TUS350.csv
This line adds an extra blank at the end of the line which causes your trouble.
SET DAT=%DATE:~6%%DATE:~3,2%
copy /Y \\srvditz1\DataXchange_R3\TUS_EXCHANGE\TUS300_digi_SFM\30_Visualization\ZPP00138_TUS350.csv \\srvditz1\DataXchange_R3\TUS_EXCHANGE\TUS300_digi_SFM\30_Visualization\Archive\%DATE:~6%%DATE:~3,2%%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%_ZPP00138_TUS350.csv
If you put directly without any variable this works.

Copy new files to another folder on windows automatically

I have a folder where some xml files keep updated, I want those files copied to another folder. From which a software collects the xml. I want to watch the folder and copy only new files as it comes to another folder automatically.
Is there any ready made solution or can it be done using Autoit, shell script or vb.net(last choice).
Main concerns:
Know when a file is added.
Copy them to the folder.
Make sure its notcopied second time.
If I schedule this code, it might also work
cd /home/webapps/project1/folder1 for f in *.csv do cp -v $f
/home/webapps/project1/folder2/${f%.csv}$(date +%m%d%y).csv done
But it again don't have a way to not copy those which are already copied.
rsync. Put it into cron to run every few minutes.

How do I create a batch script that will delete a folder on a scheduled basis?

Exact Duplicates:
How to write a batch file to delete the files which are 5 days or older from a folder?
write a batch file to delete 6 days older files from a folder
write a batch file to delete 5 daya older files from a folder
How do I write a batch file to delete folders and files on a time basis?
write a batch file to remove the folders by date and time wise.
write a script to delete files from a folder which are 5 days older than current date
How do I create a batch script that will delete a folder on a scheduled basis?
Write a batch script to delete the file
rd <YOURDIR>
and then schedule it in Windows Tasks.
Create a batch to delete the file and then place it on a scheduled task on a server or workstation.
You write your batch file and then, even better than using the Scheduler manually, you can use the at command to schedule the .bat file to run periodically.
The advantage of this is that you can put your final at command in a second bat file for easier distribution to your target systems.
at reference page on help.microsoft.com
In a text editor do the following
#echo off
rd <enter your directory name here>
Save the file as filename.bat
Create a scheduled task and select the batch file as the file to run.

Resources