File Deletion Automated in Windows - windows

We have following requirement.can anyone please help me to write bat script? if you have the script already for my requirement it would be very much appriciated.
1.Input text file will be uploaded manually in the server path e.g: E:\usr\sap\python\input.txt
2.SAP job will create output.txt in the same server path e.g: E:\usr\sap\python\output.txt
3.Once the ouput.txt is generated, that should be copied to archive folder e.g: E:\usr\sap\archive\ouput.txt
4.Once it is moved to archive folder with time stamp, the script should delete all the files in the path E:\usr\sap\python

How about this. Rather than give you the direct programming, let me guide you with a basic flow. A very simple script can do this....
Check if the file exists in the output folder.....
a. If it exists....delete the file you want
b. If it is not there.....restart the script
This is better done with something like Visual Basic and may not be entirely possible with a batch script.

Related

How execute file from parent directory without changing directories

I'm an enthusiast of efficiency. I want to execute a file in a parent directory and would appreciate it if anyone knows of a slick way to do it.
I'm using Windows command line.
lets say i have a file: C:\Documents\text.txt
and my current directory is: C:\Documents\pycode
I would like to open the textfile without changing directories or writing entire filepath.
I tried "..\text.txt" but it doesn't work.
Just add quotes.
"../text.txt"
Or, you can try this:
notepad "../text.txt"

Dynamically picking up the file name in bat file

I am running a bat file in different users laptops
Some users having this path C:\Users\%USERNAME%\AppData\Local\Google\1.8.0
some users having this path C:\Users\%USERNAME%\AppData\Local\Google\1.9.0
In my bacth file --I used only the path C:\Users\%USERNAME%\AppData\Local\Google\1.8.0
for users which are having 1.9.0 this code is not working.
Please advise
Looks like your script is using user profiles folder structure :
C:\Users\%USERNAME%\AppData\Local
This can be acheived using %localappdata% instead :
so in your script you can do as below :
CD %localappdata%
if exist Google\1.8.0 CD Google\1.8.0
if exist Google\1.8.0 CD Google\1.9.0
And then rest of your script will be same
Above code would first CD to Local folder and then search for required folder structure rest you can play with i beileve
Use a Find-n-Replace-across-files feature from a tool such as Notepad++ and change the path to whichever is the correct path for the laptop you are running from. Or if you want a batch file for that, the Find Replace tool https://findandreplace.codeplex.com/ can help. If you are doing this often, then you might want to consider AutoIT to develop your own additional script. Or, then, Python.

How to create a batch file in Mac?

I need to find a solution at work to backup specific folders daily, hopefully to a RAR or ZIP file.
If it was on PC, I would have done it already. But I don't have any idea to how to approach it on a Mac.
What I basically want to achieve is an automated task, that can be run with an executable, that does:
compress a specific directory (/Volumes/Audio/Shoko) to a rar or zip file.
(in the zip file exclude all *.wav files in all sub Directories and a directory names "Videos").
move It to a network share (/Volumes/Post Shared/Backup From Sound).
(or compress directly to this folder).
automate the file name of the Zip file with dynamic date and time (so no duplicate file names).
Shutdown Mac when finished.
I want to say again, I don't usually use Mac, so things like what kind of file to open for the script, and stuff like that is not trivial for me, yet.
I have tried to put Mark's bash lines (from the first answer, below) in a txt file and executed it, but it had errors and didn't work.
I also tried to use Automator, but it's too plain, no advanced options.
How can I accomplish this?
I would love a working example :)
Thank You,
Dave
You can just make a bash script that does the backup and then you can either double-click it or run it on a schedule. I don't know your paths and/or tools of choice, but some thing along these lines:
#!/bin/bash
FILENAME=`date +"/Volumes/path/to/network/share/Backup/%Y-%m-%d.tgz"`
cd /directory/to/backup || exit 1
tar -cvz "$FILENAME" .
You can save that on your Desktop as backup and then go in Terminal and type:
chmod +x ~/Desktop/backup
to make it executable. Then you can just double click on it - obviously after changing the paths to reflect what you want to backup and where to.
Also, you may prefer to use some other tools - such as rsync but the method is the same.

MeshLab: processing multiple files in meshlabserver

I'm new to using meshlabserver and meshlab in general.
I created the .mlx file and tries to run a command in meshlabserver for one file and it worked. I would like to know how do I write a command for hundreds of files?
Thanks in Advance.
I've just created a batch file with necessary loops and calls the .mlx file that will run the meshlabserver command. However one should know that the resulting files will be saved in the same directory where meshlabserver.exe is.

Retrieve zip file from a predefined ftp link using bat or cmd file

I have a pre-defined ftp link with a zip file on the other end that I want to save to a directory on my cloud server (running Windows Server 2008). Once the zip file has been saved to a specified directory, lets say "c:\MyZipFiles\ZipFile-1.zip" for example, I want to unzip the file so that all files contained within the zip file are accessible within the same directory. I'm currently doing this manually and I want to automate this process by creating a .bat or .cmd file that will perform these steps for me.
Once the zip file is unzipped, I have a task in the Task Scheduler of Windows Server Manager ready to use the unzipped files for other things.
The pre-defined link looks something like this:
ftp://idx.realtor.com/idx_download/files.zip
I would greatly appreciate anyone who can help me with this...
Batch file
ftp -s:ftp_cmds.txt host-name-goes-here
unzip local-file.zip
exit
ftp_cmds.txt
username-goes-here
password-goes-here
cd remote-directory-goes-here
get files.zip local-file-name-goes-here.zip
quit
This the batch file uses "unzip" to unzip the archive you can find it here: http://gnuwin32.sourceforge.net/packages/unzip.htm
Either put the binaries in the same directory or put them somewhere else and set your windows PATH
I used my own ftp to test most of this. Your ftp was offline for me, so it might take some tweaking but this should put you in the right direction.

Resources