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

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.

Related

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

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"

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.

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.

How to extract date from filename in batch, and unzip to multiple directories using batch/7z

I am trying to code a script to automatically process some of our daily ftp files.
I have already coded the files to download from the source ftp using WinSCP and calling it in a .bat file, and would ideally like to call it within the same bat. Scripting Language does not matter, as long as I can run/call it from the original batch.
I need will extract the date from a filename, and unzip the contents into corresponding folders. The source file is delivered automatically daily via FTP, and the filename is:
SOFL_CLAIM_TC201702270720000075.zip
The bolded section is the date that I would like to extract.
The contents of the .zip include two types of content, multiple PDFs and a .dat file.
For the supplied date of 20170227, the pdfs need to get extracted to a folder following the format:
\%root%\FNOIs\2017\02-Feb\02-27-2017
At the same time, the .dat file needs to get extracted to multiple folders following the format:
\%root%\Claim Add\2017 Claim Add\02-2017
\%root2%\vendorFTP\VendorFolder
After extracting, I need to move the source zip to
\%root%\Claim Add\2017 Claim Add\02-2017
What is the best way off accomplishing all of this?
I am assuming it would be the for /f batch command, but I am new to batch coding and cannot figure out how to start it from scratch.
I also have 7zip installed, but do not understand how to use the command-line options.
You have asked for a lot in one question, and not shown any code or demonstrated effort on your part.
For the first part, once you have the filename in a variable:
set FILENAME=SOFL_CLAIM_TC201702270720000075.zip
You can get the date part with:
echo %FILENAME:~13,-14%
The syntax: :13,-14 means "Remove the first 13 letters and the last 14 letters." That should leave you with just the date.
When you integrate that into your script, Show Your Code

How to change identical line/dir in multiple bat files?

I would like to update a line in a few different batch files at the same time.
How would I go about writing something to change multiple identical lines in a file.
Specifically, every week I have a BAT file create a new folder labeled "Week monthdayyear"
I have other BATs that have been made to move files to that new folder throughout the week. Currently the only thing I know how to do is manually change the date in each of the BATs that move files to that folder every week. I would like to have my BAT file that creates the new directory to modify the other BATs and input the new directory.
Example:
Each Bat Contains:
ren "...\Week 4-13-2015\..."
I need to change each bat to say
ren "...\Week 4-20-2015\..."
This question is related to another question I asked a week ago. I solved the other question if you want to use it as reference for more background information and the actual scripts.
Can a Batch File Tell a program to save a file as? (If so how)
You have a problem of inter-program communication, that is, the program that create the new folder every week needs to inform to the rest of programs the name of the current folder. You may do that via an auxiliary data file. For example, include this (or similar) line in the program that create the folder:
echo Week %monthdayyear%> CurrentWeek.txt
... and get the right name in each one of the rest of programs:
rem Get the name of the current folder
set /P currentFolder=< CurrentWeek.txt
. . .
ren "...\%currentFolder%\..."

Resources