What's the coolest hack you've seen or done?
I just changed mplayer to woplayer,
and I don't see what this does:
findstr /I /R %1 dirlist.txt > playlist.txt
What's dirlist.txt?
That meant to be you full playlist, i.e. all your music files. You can make one by typing:
dir c:\*.mp3 /s /b > dirlist.txt
Dirlist.txt is a text file with the list of the songs. With findstr you are searching inside this file for a pattern matched with %1, the first argument passed when calling to this .bat file.
So, if you don't have a file with the list of your songs, this will not work.
dirList.txt appears to be a text file you have already filled in containing the filenames of all your music tracks (one on each line of the file).
The batch file then filters out only the filenames that include the string that you specified (using a regex match), and makes a new, shorter list (playlist.txt) which can then be sent to your music player application to get it to play those tracks only.
Note that "woplayer" has to support playing a playlist in the same way as "mplayer", or the trick won't work - you may not necessarily be able to just substiture one program for another.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed last year.
Improve this question
I just discovered that GIMP 2.10 removes JPG EXIF data because of the "PENTAX" in uppercase present in the EXIF data (the bug is described here and here).
Tried Exif Pilot freeware and found out the EXIF fields:
Make=PENTAX
Model=PENTAX K-x
Fixing them to "Pentax K-x" and "Pentax" solves the problem but requires me to do it manually one by one in Exif Pilot GUI.
Is there any way to do this as batch for a whole folder with JPG files? I tried to find some Exiftool parameters to replace "PENTAX" with "Pentax" but to keep the model information correctly but no success so I would appreciate help.
thanks
Using exiftool, you could use this command
exiftool -api "filter=s/PENTAX/Pentax/" -TagsFromFile # -Model -Make /path/to/files/
The -api Filter option will do a regex substitution changing PENTAX into Pentax. The -TagsFromFile option will copy the modified Model and Make tags back into the file. It will not affect any file that doesn't contain PENTAX in those two tags.
This command creates backup files. Add -overwrite_original to suppress the creation of backup files. Add -r to recurse into subdirectories.
Windows is lacking in having the generic command grep for this common task on many other systems. The jpeg files are binary but like a PDF the Meta data itself is held as plain text. Do check your text string is similar to below otherwise you will/may need to parse both PENTAX entries separately as single words.
So in this fixed case it it should be easy to use any binary file reader / writer and "Find aNd Replace" the text string. Just ensure it is byte for byte the same length.
Find =PENTAXPENTAX K-x
Replace =PentaxPentax K-x
DO NOT use Notepad and sadly the native cmd tool Debug.exe was removed long ago. However you might use inbuilt PowerShell of which lit is an advocate. :-)
You could use the well known exiftool but that is yet another exe to add to your dedicated file utilities collection.
Otherwise consider downloading a more universal small CMD batch file like dbenhams jrepl.bat which can be used for hundreds of other file type tasks.
jrepl PENTAXPENTAX PentaxPentax /M /f user-default-avatar.jpg /o -
So the code you need to consider is how you write a loop for doing all your files and thus I will suggest you use For /? and look at the options to add a folder of files something like For %F in (*.jpg) do jrepl ... However, as there are no error checks or backup, I suggest it be something like this
#echo off & Title Replacing PENTAX
set "Find=PENTAX"
set "Replace=Pentax"
for %%F in (*.jpg) do #(
echo replacing %find% in %%F
if not exist %%~nF.bak copy %%F /B %%~nF.bak /B >nul
#jrepl "%Find%" "%Replace%" /M /F %%F /o -
)
I have ZERO bat knowledge so thought I would ask here, if I may.
I have an image C:\Users\Dane\Pictures\Doom.jpg. I wish for this image to be copied and for it to be renamed to the exact name of 379 non-image type files which are in another folder which is G:\Doom. So I will have the same image 379 times but named to match the 379 files.
Would anyone be kind enough to write a bat file to do that? Thank you in advance.
This site is not a free code writing service; Rather give the subject an attempt and we will be happy to assist you. However, because I'm nice, I have a response for you.
This problem is pretty common and can be solved very easily using a FOR statement. In this example we will be searching a directory for every item stored inside. Each item will be added to the integer %%A. For more information do FOR /? inside a command window.
for %%a in ("Directory") DO (Action)
For copying files, we will use the copy command. Please keep note that we will be using parameter extensions to expand the %%A to have no extension using %%~na. More info here: Parameter Extensions
This script will copy & rename Doom.jpg to G:\Doom for each item in the directory.
Batch File:
for %%a in ("G:\Doom\*") do (copy "C:\Users\Dane\Pictures\Doom.jpg" "G:\Doom\%%~na.png")
Command Prompt:
for %a in ("G:\Doom\*") do (copy "C:\Users\Dane\Pictures\Doom.jpg" "G:\Doom\%~na.png")
I’m looking for a way of using 7Z to zip several files with the same into a .7z/.zip file.
Within my directory I have hundreds of files with differing amounts of ‘tracks’ like so;
Zebrafile.cue
Zebrafile (Track 1).bin
Zebrafile (Track 2).bin
Donkeyfile.cue
Donkeyfile (Track 1).bin
Donkeyfile (Track 2).bin
Donkeyfile (Track 3).bin
Extradonkeyfile.cue
Extradonkeyfile (Track 1).bin
And I need a way of zipping these files together automatically so I just end up with
Zebrafile.zip
Donkeyfile.zip
Extradonkeyfile.zip
I guess the script would have to match the whole filename from the start UP TO the space before the opening bracket "(" somehow! The only variable after that match would be the number of the track "(Track X)"
Would anybody be able to point me in the right direction? I have seen other batch files which get close, but I'm still unsure of how to get the batch file to take into account the changing Track #. Many thanks!
Something like the following might work. If it is in a .bat script, double the '%' on the 'f' variable. This will put the .cue and .bin files into one archive file. If you want a .zip format file, use -tzip.
FOR /F "tokens=*" %f IN ('DIR /B /A:-D "*.cue"') DO (7z a -tzip "%~nf.zip" "%~f" "%~nf (*.bin")
It it actually possible to get XCOPY to append, as per
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true
To append files, specify a single file for destination, but multiple files for source (that is, by using wildcards or file1+file2+file3 format).
?
Neither wildcards or file1+file2+file3 format works for me.
Workaround (sometimes): Use COPY instead.
If I get it right, you want to merge files into one. For text files I would use:
FOR /R %%f in (file*) DO TYPE %%f >> bigfile
The copy command supports concatenation natively:
copy <srcFiles> <destination>
It will list the files as it copies them, and the result will be in the target directory. This is more efficient than using TYPE (which you could also achieve with TYPE file* >> bigfile for the #Diodak answer, rather than using FOR loop.
I am a Batch-newbie, so please accept my apologies and Thanks in advance !
This "tool" is to automate the slimming down of Windows (XP) by disabling certain system driver, DLL and EXE files. Instead of outright deletion, I wish to rename-in-place, thus "removing" them from the OS, but not losing sight of where they belong (should any need to be "restored"). Renaming is accomplished by appending a new suffix to the existing filename (eg: "wdmaud.drv.group_1") The renaming suffix should be another input variable.
The target-list is approx. 1100 files long (divided into various groups/phases), so manual renaming is out of the question. Each group will be processed in a separate run of the batch file, varying the target-list input file for each execution.
Target-list is plain text file, one filename per line (no other data in the files). Number of entries per group varies. Target list will look like this:
-- example start --
netapi.dll
netcfgx.dll
netdde.exe
netevent.dll
neth.dll
netid.dll
netrap.dll
nic1394.sys
-- example end --
Filenames may be in UPPER, lower, or MiXeD case. The files may be present in more than one folder in the C:\Windows hierarchy - or may not be present at all. If a file is not found anywhere in the system, it's name should be written to a text file, one-entry-per-line.
The specific folders of interest are:
C:\WINDOWS\
C:\WINDOWS\system\
C:\WINDOWS\system32\
C:\WINDOWS\system32\dllcache
C:\WINDOWS\system32\drivers
The renaming will be done by connecting the target OS drive to another XP computer, so locked system files should not be a problem.
Any help you can offer will be greatly appreciated.
a double FOR loop may help you.. this is a very simple example, just to get you started
for /f "tokens=*" %%f in (%targetlist%) do (
for /f "tokens=*" %%d in (%dirlist%) do (
if exist "%%d\%%f" echo %%f found in %%d
)
)
see HELP FOR.