How would i go about writing a .bat file, so that i can drag and drop a file onto it in windows 7, that would copy the file to the same directory, but on a different drive?
So if my file was:
D:\Files\Newfiles\File01.jpg
It would copy it to a prespecified network location (COMPUTER_01):
\\COMPUTER_01\Files\Newfiles\File01.jpg
I've looked into using command line parameters %~p1 and %~nx1, but i'm not sure how these would be implemented.
I'm sure this is painfully easy to do but I have no idea!
Painfully easy it is:
copy %1 "\\COMPUTER_01%~p1"
Related
I'm trying to create an inf file containing a command which opens a .bat file, but it doesn't work.
I've used "run=", "open=", "shellexecute=" but nothing worked.
I've also tried to plug the removable disk, (which contains the inf file), into another computer, but still doesn't work.
Additionally, I've also tried other commands like "icon=" and which works. But when I use the command "run=", "open=", etc. I still can't open the .bat file that I created, and have placed in the same removable disk.
i'm a near complete beginner to batch scripting.
I'm currently learning how to create batch files. My goal is to compress a folder using exclusively InfoZip, add the date to the file name, and have that file copied to an USB memory stick plugged on H:\
The reason why i need to use InfoZip, even though it is a very old program, is because i need somthing that works even on Win95.
InfoZip is not installed, it is just unpacked in folder and ready to use.
It is possible to download InfoZip 3.0 from here:
https://sourceforge.net/projects/infozip/
Anyway, so far, the only thing i could come up with is this...
--------------------------------------
Title : Your folder will be zipped into an archive that will be copied on the USB memory stick plugged on your computer. Please DO NOT remove the memory stick during the operation.
#ECHO OFF
call d:\infozip\wiz.exe
pause
--------------------------------------
It just brings up the InfoZip window on the screen, but then i have absolutely no idea about how to make it zip a folder, add the date, and copy that zipped file to the USB.
All the regular commands meant for 7-zip or Winzip don't seem to work with InfoZip.
I could really use some help, please :)
Thanks!
Using the waybackmachine I was able to get the documentation for info-zip:
https://web.archive.org/web/20170829173722/http://www.info-zip.org/mans/zip.html#EXAMPLES
In contrary to what zip.exe shows, the syntax for zipping files is this:
zip -r zipfilename zipfilecontents
Example:
zip -r myzip.zip c:\myfolder\*.*
The -r parameter includes subfolders as well.
Problem is that the complete folder structure is included in the zip. I have not found a solution for this yet.
To solve the structure folder problem, add a cd command that will target the folder container which has inside your file or files. This before running the code proposed by Martien de Jong upside.
for example:
The path of my file is: cd C:\aa\B\file.txt
So the path you will put in the cd to target the folder container is: cd C:\aa\B
cd C:\aa\B
zip -r myzip.zip B\*.*
*Remember that this code will zip all the files included in B folder.
I am trying to copy a file from the C:\ drive to the steam directory using this
copy "C:\CSS.zip" "C:\%ProgramFiles86%\Steam\CSS.zip"
but it always makes a new folder and places the file in a new folder called %ProgramFiles86% but i want it to go in the actual Program Files (x86)
Thanks for the help
You aren't using the program files path correctly. Your code should be this:
copy C:\CSS.zip "%programfiles(x86)%\CSS.zip"
How can I make a batch file move files from the directory it is running from? For example code:
**move {***CURRENT BATCH FILE DIRECTORY***}\Programs\myfile.txt**
What do I replace {***CURRENT BATCH FILE DIRECTORY***} with?
When you say "the directory it is running from", I assume you mean the folder that contains the currently executing batch file. If so, then you want %~dp0. The expansion will automatically append the trailing backslash.
move "%~dp0Programs\myfile.txt" "target folder"
Don't the "." (dot) work for you? I mean:
move .\Programs\myfile.txt
This works in Windows, if the current directory is where Programs is.
move "Programs\myfile.txt" "target folder"
I have written a small batch file to move files from one folder to another folder.
copy E:\Source\Test.tif E:\Temp
Is there any way can I rename a file name after it has been moved to temp folder.Like
E:\Source:\TestInd1.tiff.
Please suggest.
You can do a move and a rename at the same time, yes:
move someFile S:\ome\Destination\newName