Renaming files that start with - windows

I've created a batch script to automatically update some files using wget for Windows. It downloads a file with a version number in the filename, for example server-2.0.exe. I want to automatically rename the file to server.exe.

I think that wget has the option directly in its commands.
--output-document=file

This might do what you want, depending on how variable the filenames are:
ren C:\server*.exe server.exe

Try this:
ren server????.exe server.exe

Related

Combine mkv's in Windows (automated, not using a GUI)

From time to time I receive several mkv's from a server I have. These mkv's are all part of the same recording, but they come in 1 minute chunks, and I don't want to have to take the time to stitch them together manually each time. Can this be done via an automated process in Windows?
EDIT: See my answer below for the solution that worked for me. The post by Endoro also looks promising.
I can give you an example:
#echo off &setlocal enabledelayedexpansion
cd /d "%sourcefolder%"
set "line="
for %%a in (*.mkv) do set line=!line! +"%%~a"
mkvmerge -o "output.mkv" %line:~2%
As I continued researching, I discovered a download page that also contained a review of mkvtoolnix (http://www.fosshub.com/MKVToolNix.html) that referred to some cmd commands he tested along with the standard GUI test. using the "mkvmerge --help" command, I was able to determine the appropriate command to stitch mkv files together. It looked something like this:
C:\Program Files (x86)\MKVToolNix>mkvmerge file1.mkv + file2.mkv --output C:\Users\User1\mkvfolder\combined.mkv
This stitched two mkv files together (that were located in the MKVToolNix folder), and puts the combined.mkv file in a different directory. It seemed to me that changing the source directories for either of the original mkv's (file1.mkv, file2.mkv) should be possible as well, so I next tried this:
C:\Program Files (x86)\MKVToolNix>mkvmerge file1.mkv + C:\Users\User1\Documents\file2.mkv --output C:\Users\User1\mkvfolder\combined.mkv
The above code merged file1.mkv (which I had placed in the mkvtoolnix directory) with file2.mkv (which I had located in a different directory), and placed the merged file (combined.mkv) in a third directory. The merged file ran cleanly in vlc, with no hiccups at the stitchpoint.
TL DR: go to http://www.fosshub.com/MKVToolNix.html, download MKVToolNix, and use the command line to merge mkv's.
You could try using AVIDemux with the --append arg. On this link there is also a batch file example script.

how to batch replace the files in a directory windows vista(from .txt.txt to .txt)

I have a couple of flat files(.txt) in a directory.all those files are in the format *.txt.txt so i want to rename it to *.txt ?Is there any simple way to rename all together?
when I tried ren *.txt.txt *.txt is is not working
Any experts please suggest?It is amazing I have not got any answer yet
Please be noted that I need an out of the format filename.txt.
This should work
ren *.txt.txt *.
The reason your command didn't work is because, to windows, the file file.txt.txt is called file.txt with a .txt extension.
Only the last extension is the real extension, the first then becomes part of the filename, hence why your command changes it to what it already is.
If you did ren *.txt.txt *.pdf you would get file.txt.pdf.
My command will just remove the last one, thereby leaving the first, which then becomes the only and real extension.

Batch file to detect only part of a filename

I need a snippet of a batch file that can detect part of a filename, then rename it.
Note that the numbers after the filename change randomly but "file" is always the same.
Example:
filename: file143424
There will always be only one file that needs to be renamed in the folder. The script will delete older versions of the file. For instance, I put a first file inside the folder and the script in there too. I then run the script, which renames it to just file. Then if I put a new file in, the script, when run again, will recognize it from the "file" prefix and rename it to file after deleting the old one.
Excuse me. Your question is incomplete, I think. You want to rename "file134342" to what?
In your comment you said: rename it to just "file", but this works only if there is just one file with that name. Anyway, here it is:
for %%f in (file*) do ren %%f file
If this is not what you want, then give us more details (you showld always give full details from the very beginning).
You can check for the first four characters that way:
if "%filename:~0,4%"=="file" ...
#Aacini's suggestion should work fine in your case. But you could do very well without a for loop, a single REN (RENAME) command would be enough:
RENAME file* file

Copy All Files and Directories & Subdirectories in SAS

I used the follwoing statement to copy over files from one folder to another... but it does not copy over the subdirectory (and the files and folders under that subdirectory)
%sysExec copy "&driv.\&path1\*" "&driv.\&path2";
Any Solutions?
I don't think this is a SAS question. This would depend on your enviroment.
If you are on Windows, try xcopy
If you working in another environment, post additional info
I usually use a FILENAME PIPE for this, and then execute through a data step. The standard output is then captured in the data step. I've not got SAS available at the moment, but it would look something like this:
filename mycopy pipe """xcopy "&driv.\&path1\*.*" "&driv.\&path2\""";
data copydir;
infile mycopy;
input;
stdout=_infile_;
run;
You can check the data set's STDOUT variable for feedback on what happened.
If you're still running into trouble, then test the command you're running from the command line first and then transfer to your SAS code.
Try this . . .
%sysExec xcopy "&driv.\&path1\*.*" "&driv.\&path2\*.*" /s;
The /s option copies all subdirectories - provided they are not empty.

Using bash to get the files rar creates

I'm running the command
rar a -m0 -v100m rarname.rar *.*
On some files with a bash script. I know I specified the rarname, but because of the -v option which sets a size limit to the rar, this command can make lots of rars named rarname.part1.rar, rarname.part2.rar, etc.
What is the best way to get the list of files created?
This should do it:
rarname.*.rar
Globs are not limited to the DOS-style "name.ext" pattern.
You can either capture and parse the output from the rar command or create the rar'ed files in a temporary directory, and then process the files there.
I'd recommend the later option.

Resources