I'm trying to automate a task with a batch-script. Basically it should take a .html-File and a directory and zip them together.
7z a -r MyZIP.zip .\My-Folder
7z a MyZIP.zip .\MyFile.htm
It also "works". I can unzip it and I get everything back the way I put it in. Now I'm unzipping this on an iOS device and the folder suddenly is a 0 byte file without content.
I've compared the ZIP created by my script and the one I get when I do it by hand and it looks like the attributes on the folder are set differently.
When I do it by hand (then it works btw.) the folder has the attribute "D" and when my script does it it has the attribute "DA".
Does anyone have an idea why or how I could remove the "A"-attribute?
Any help would be appreciated.
Ok it turns out it wasn't 7zip that was creating the issue, but the xcopy command. When I copied by hand the directory had the correct 'D' attribute.
To make it work I switched from xcopy to copy
Related
i want to create a portable roblox but these bothers me
i am not so good at batch file but how to i run these exe under these directory i mean
if roblox has an update the "version-3bxxxxxxxx" will change and i cannot run the exe anymore
start "" "C:\Program Files (x86)\Roblox\Versions\version-3b33190189084158\RobloxPlayerLauncher.exe" -app
start "" "C:\Program Files (x86)\Roblox\Versions\version-3b33190189084158\RobloxPlayerLauncher.exe" -app
i try to search on the internet give nothing more =(
I hope you found the help you needed by now, sad no one responded after all this time. This is not as elegant, but I had the same issue and I did this as my solution:
cd\Progra~2\Roblox\Versions\version-* <-just need a "*" wildcard there
start RobloxPlayerLauncher.exe -app
Hope this helps others that want to run a batch file for programs like Discord and Roblox etc. as their directory names always change with updates.... The practice is annoying and I wish devs would consider end users setups.
rEd2k's answer is fine for use directly on the command line. With a batch script, you can automate it.
Search for the exact folder name with a for /d loop and use the found folder as working folder with the start command:
for /d %%a in ("C:\Program Files (x86)\Roblox\Versions\version-*") do set "rootdir=%%a"
start /d "%rootdir%" RobloxPlayerLauncher.exe -app
NOTE: if there is more than one matching folder (versions), rootdir will contain the last found folder (by string sorting on NTFS), which is probably good enough.
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.
im working on a script that have few folders and i don't really understand how to make an config for this but i don't need it.
i have setup a script config inside
Set cfg=cfg2
Set txt=txt2
Set rar=rar2
cfg2, txt2, rar2 are in a diffrent directory
the files in cfg are cfg files but theres alot of them.
this also goes for txt & rar too.
i want a copy script that copies all cfg files (and only cfg files) into the cfg2 file that are in another directory.
and then this goes again for the txt & rar files.
I also know the code for move but i really want to copy it
cause on move you just do
move "txt/*.txt" %txt% and thats kinda what i want to do but that aint working
Have a look at robocopy from microsoft.
Something like the below should work;
robocopy /s \path\cfg \path\cfg2 *.cfg
Im writing a batch file for work. basically my command right now navigates to a file path, then prints out the contents of the folder with the dir command.
Without giving the specifics away of what i am trying to print out here is the code im using
CD C:\Some folder\some folder2\some folder 3\some folder 4
DIR
now in "some folder4" there are 3 files. If i use the code
CD C:\Some folder\some folder2\some folder 3
DIR
It prints out fine that there is a folder "some folder4" in "Some Folder3", but as soon as i change the directory into the "some folder4" folder it says file not found instead of showing me the 3 files that are in it.
Any advice as to what would be causing this
I think we need more specifics of what you're doing here (you're going to have to give away a bit more), but one thing you should definitely look at is the for /d command instead of DIR.
You know you can use a filespec with the DIR (or for) command right? Changing the directory isn't really the best choice - especially since drive and relative paths are assumptions. [cd h:\test\ doesn't switch drive if you're on c:\, but dir h:\test\ will work no matter what drive you're on]
If your folders have spaces in them, it could be you need to escape the folder name with quotes (cd "some folder4").
I have a batch file I've created which uses xcopy to copy a dir, and child dirs, and merge them into one file. (ie. all my modulised development css stylesheets merged into one production stylesheet).
Everything is good, apart from the fact that when I reference the excludelist.txt, it only excludes the first line, and not the subsequent files I want excluded.
Anyone fancy a crack at this? You'd be most helpful.
Here's the code:
XCOPY C:\xampp\htdocs\PROJECT\css\*.* C:\temp /S /I /Y /EXCLUDE:C:\xampp\htdocs\PROJECT\exclude.txt
...and inside my exclude.txt is...
1.css
2.css
3.css
4.css
5.css
///// I know the code works (to an extent) because it is infact excluding file 1.css -- just not the ones below it. Am I right to put each exclusion on a new line?
I use the following,
xcopy "C:\users\dad\*.*" dad /s /d <yesnoyesno /EXCLUDE:excluexclu 1>cop.txt 2>err.txt
as somewhere on the web I saw a note to the effect that the /Y switch could not be used directly with an exclude file.
What I wanted to point out here, was the useful output files 1 & 2, which detail the success & failure issues.
Mine shows only success.
The short answer: Create a new text file, type the entries and save the file.
The longer explanation: I ran into this very issue on a Windows 2008 server today. I tried all kinds of things to get it to work. Forced notepad to save the file as ANSI, Unicode and UTF-8 but all of them had the same problem. Finally I started thinking about the fact that I put the file on the server via FTP and it's quite likely that FTP tweaked the file format. I created a new text file on the server, typed all the same entries in the new file and now it works.
I had a similar problem. I was trying to exclude all files with a certain extension in the root folder and any sub-folders and it didn't work. The reason was I was putting *.pdb instead of just .pdb. The newline/carriage return thing was a total red herring for me.
So my file just looked like:
.pdb
.obj
.vb
.cs
You seem to be using xcopy correctly - each exclusion file (or match depending on wildcards) should be on a new line within the file. So far I've been unable to reproduce the behaviour you're experiencing.
Is the exclude.txt listing you've given above a test file, or are they the actual css names?
What are the names of the other files that your batch file is supposed to copy?
Edit:
That the xcopy is failing to exclude further files after a single match is giving me most pause. I thought it might be to do with the type of carriage-return that was used in the exclude file, but xcopy handles unix-style carriage-returns just fine.
Can you re-verify that the correct exclude file is being used?
Try forcing it to save with ANSI encoding on your text editor.
I was having a similar issue and that did it.