|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
move script
hi guys i have a simple question
i have a directory with name of files in /tmp which contain some files i want to check all files with file command and if they were MP3 or Wave sync them into new place . for example ( /root/mp3 ) i find all files and remove white space and rename them next i check them with file command and if they were mp3 or wave we should sync or copy them with exact path into new place eg. /tmp/files/test1 ------> /root/mp3/test1 /tmp/files/New/test2 ----------> /root/mp3/New/test2 /tmp/files/New/last/Old/test-old ------------> /root/mp3/New/last/Old/test-old files should copy into same directory in new the place what can i do ? i think to echo $new |sed "s#/tmp/files#/root/mp3" but it doesnt work ![]() what can i do ?? PHP Code:
|
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Try: Code:
#!/bin/bash
old=/tmp/files
new=/root/mp3
find $old -name "*.*" | while read FILE
do
newf=$(echo $FILE | sed 's/ /_/g')
ndir=$new${FILE#${old}}
ndir=$(dirname $ndir)
[[ -d "$ndir" ]] || mkdir -p "$ndir"
mv "$FILE" "$ndir"
file "$newf" |egrep -w 'MP3|WAVE'
if [ $? = 0 ]
then
cp .................
fi
done |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script to move all files in a dir into a certain dir | sherresh | Shell Programming and Scripting | 2 | 06-17-2012 04:56 PM |
| Script move files by name | corfuitl | Shell Programming and Scripting | 5 | 03-11-2012 08:12 PM |
| Move Script | treds | UNIX for Dummies Questions & Answers | 8 | 06-02-2009 11:22 AM |
| script to move | darshakraut | Shell Programming and Scripting | 2 | 05-22-2009 06:02 AM |
| Help with Copy Move Script | alfpathros | Shell Programming and Scripting | 4 | 05-11-2004 08:52 AM |
|
|