By martin
Mon Jan 10, 2011 10:44 am
I just made a script that will sync your MPC to your computer's sample library, and after that trim the file names on the MPC to 16 characters. The good thing is that it will remember the original (long) file names, so it will only copy the samples that have actually changed since last time. If you (like me) have all your samples on your MPC's 16GB CF card, this is very important
This will only work on Unix systems like Mac OS X and Linux. Windows users need to use Cygwin. Use at your own risk.
Here's how to use it:
1. Create an empty file on your desktop, let's name it "mpcsync" (without ".txt" or something)
2. Edit that file and paste the following into it:
Make sure you edit the MPCFolder and Localfolder line at the top. MPCFolder should point to your MPC hard drive / CF card when it's connected via USB. Localfolder should point to the sample library on your computer.
Save the file.
3. Open a Terminal (it's in /Applications/Utilities/) and run the following command:
The icon on your desktop will change.
You can now connect your MPC by USB (or plug in your card reader) and double-click the black icon on your desktop. After it closes, the sample folder on your MPC will be the same as the sample folder on your computer.
This will only work on Unix systems like Mac OS X and Linux. Windows users need to use Cygwin. Use at your own risk.
Here's how to use it:
1. Create an empty file on your desktop, let's name it "mpcsync" (without ".txt" or something)
2. Edit that file and paste the following into it:
Code: Select all
#!/bin/bash
# MODIFY THESE:
MPCFolder="/Volumes/MPC500 DISK"
Localfolder="/Users/martin/Musikmachen/samples"
num=1
length=16
# Rename all files to their original long form
cd $MPCFolder
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for dir in $(find $MPCFolder/samples -type d); do
cd $dir
#echo "dir: $dir"
for i in $dir/*.wav; do
#echo "i: $i"
searchstring="SHORT $i"
linenumber=`grep -n "$searchstring" $MPCFolder/longfilenames.txt`
linenumber=${linenumber/\:*/}
#echo "$searchstring FOUND IN Line #${linenumber}"
(( linenumber++ ))
originalname=`sed -n ${linenumber}p $MPCFolder/longfilenames.txt`
originalname=${originalname:5}
#echo "Short Name: $i"
#echo "Origi Name: $originalname"
mv "$i" "${originalname}.temp"
done
done
# echo "FIRST STEP DONE, ALL FILES ARE LONG AND HAVE .temp EXTENSION"
for dir in $(find $MPCFolder/samples -type d); do
#cd $dir
for i in $dir/*.wav.temp; do
mv "$i" "${i/\.temp/}"
done
done
IFS=$SAVEIFS
# Synchronize the folders using rsync. It will ignore hidden files/folders. The modify-window is needed on FAT32 in some cases.
rsync -avzti --delete-before --modify-window=3602 --ignore-errors --exclude='.*/' --exclude='.*' --progress "$Localfolder" "$MPCFolder/samples"
# Shorten file names:
cd $MPCFolder
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
mv $MPCFolder/longfilenames.txt $MPCFolder/longfilenames.old
touch $MPCFolder/longfilenames.txt
for dir in $(find $MPCFolder/samples -type d); do
cd $dir
#echo "dir: $dir"
for i in $dir/*; do
#echo "i: $i"
FilenameWithoutDir=${i/$dir/}
FilenameWithoutDir=${FilenameWithoutDir:1}
FilenameWithoutExtension=${FilenameWithoutDir/\.*/}
#echo "FileNameWithoutExtension: $FilenameWithoutExtension"
Extension=${FilenameWithoutDir/$FilenameWithoutExtension/}
#echo "Extension: $Extension"
# echo "FilenameWithoutDir: $FilenameWithoutDir"
newname=$FilenameWithoutExtension
until [[ ! -f $newname$Extension ]]
do
(( sublen = length - ${#num} ))
printf -v newname '%.*s%d' "$sublen" "$FilenameWithoutExtension" "$num"
(( num++ ))
done
# echo "newname: $newname"
#echo "Moving $FilenameWithoutDir -> $newname$Extension"
# Save the original name so we can restore it next time
echo "SHORT $dir/$newname$Extension" >> $MPCFolder/longfilenames.txt
echo "LONG $i" >> $MPCFolder/longfilenames.txt
mv "$FilenameWithoutDir" "$newname$Extension"
num=1
done
done
IFS=$SAVEIFSMake sure you edit the MPCFolder and Localfolder line at the top. MPCFolder should point to your MPC hard drive / CF card when it's connected via USB. Localfolder should point to the sample library on your computer.
Save the file.
3. Open a Terminal (it's in /Applications/Utilities/) and run the following command:
Code: Select all
chmod a+x ~/Desktop/mpcsyncThe icon on your desktop will change.
You can now connect your MPC by USB (or plug in your card reader) and double-click the black icon on your desktop. After it closes, the sample folder on your MPC will be the same as the sample folder on your computer.
Last edited by martin on Tue Jan 11, 2011 4:56 pm, edited 3 times in total.







