LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-01-2017, 06:55 AM   #16
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,499

Original Poster
Rep: Reputation: 833Reputation: 833Reputation: 833Reputation: 833Reputation: 833Reputation: 833Reputation: 833

Quote:
Originally Posted by Guttorm View Post
I tried it on the list in the first post. It looks like it overgenerates duplicates because of the Xtc prefix.

So then i cut of the "Xtc-" prefix, and it works well:
and @syg00
yeah - just the names I am going to worry about.
almost got it. I just got to slap it in a script and fiddle with it - that should get me where I want to be. got a figure out how to chop off the Xtc- then work with in in a script, because CLI isn't getting me anywhere.

It might just be the way it outputs and not looks at it, I do not know. I am trying to chop off the Xtc- within the $(bash fuzzy.sh "${name#*-}" ; echo "${name#*-}" ) part as my putting it before that wasn't getting me anywhere either.
Code:
userx%slackwhere ⚡ Xtc Live ⚡> while read name ; do echo   $(bash /home/userx/scripts/production/fuzzy.sh "${name#*-}" ; echo "${name#*-}") ; done< <(find "/run/media/userx/3TB-External/Test-Duplecates-files/Xtc/Xtc Live" -name "*.mp3")  | sort | uniq -d -w 4 -D                             
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Are You Receiving Me?.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-AreYouReceivingMe?.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Battery Brides.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Burning With Optimism's Flame.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Generals And Majors.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Life Begins At The Hop.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-LifeBeginsAtTheHop.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Living Through Another Cuba.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Love At First Sight.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Making Plans For Nigel.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-No Language In Our Lungs.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Respectable Street.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-RespectableStreet.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Scissor Man.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-This Is Pop?.mp3
E236 External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Towers Of London.mp3
MOD:
ok I go one thing figured out so far - I had to go long ${name##*-} on just the one being passed to fuzzy.sh

this is better
Code:
userx%slackwhere ⚡ Xtc Live ⚡> while read name ; do echo   $(bash /home/userx/scripts/production/fuzzy.sh "${name##*-}" ; echo "${name}") ; done< <(find "/run/media/userx/3TB-External/Test-Duplecates-files/Xtc/Xtc Live" -name "*.mp3")  | sort | uniq -d -w 4 -D                               
A662 /run/media/userx/3TB-External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Are You Receiving Me?.mp3
A662 /run/media/userx/3TB-External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-AreYouReceivingMe?.mp3
L112 /run/media/userx/3TB-External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Life Begins At The Hop.mp3
L112 /run/media/userx/3TB-External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-LifeBeginsAtTheHop.mp3
R212 /run/media/userx/3TB-External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-Respectable Street.mp3
R212 /run/media/userx/3TB-External/Test-Duplecates-files/Xtc/Xtc Live/Xtc-RespectableStreet.mp3

Last edited by BW-userx; 06-01-2017 at 07:33 AM.
 
Old 06-02-2017, 08:58 AM   #17
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,499

Original Poster
Rep: Reputation: 833Reputation: 833Reputation: 833Reputation: 833Reputation: 833Reputation: 833Reputation: 833
The script that works (sofar)

Searches for liked named files then removes one keeps the other.
Code:
#!/bin/bash

working_dir=/run/media/userx/3TB-External/Test-Duplecates-files

move_to=/run/media/userx/3TB-External/Hold-Test-Files

#set -x
while read FILENAME
do
{
f=$FILENAME
path=${f%/*} 
xfile=${f##*/}
title=${xfile%.*}
ext=${xfile##*.}
while read FILE
do
{
f=$FILE
path=${f%/*}
xfile=${f##*/}
title2=${xfile%.*}
ext=${xfile##*.}

#check for spaces in string in first loop if spaces then look for string without spaces in inner loop
#              Has Spaces in string                         Has NO spaces in string
if [[ "$title" = "${title%[[:space:]]}" && "$title2" =  "${title2%[[:space:]]*}" ]] ; then
#remove spaces in first string to check against second string without spaces
CKtitle=${title// /}
  [[ "$CKtitle" =~ "$title2" ]] &&  (
    #if now matched remove second file without spaces
    getRidOf=${path/$working_dir/$move_to}
    mkdir -pv "$getRidOf"
    mv -v "$path/$title2.$ext" "$getRidOf"
)

fi
}
done< <(find "$path" -type f \( -name "*.mp3" -o -name "*.MP3" \))
}
done< <(find "$working_dir" -type f \( -name "*.mp3" -o -name "*.MP3" \))

Last edited by BW-userx; 06-02-2017 at 09:02 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script- text file manip- delete everything before/after string justin99 Programming 9 11-20-2014 03:16 AM
Bash script to delete folder's that are listed in a text file Bone11409 Programming 26 01-16-2009 02:55 PM
Need a bash shell script which will delete lines from file scjohnie Linux - Newbie 1 09-13-2008 08:51 PM
How to run a BASH script in a Batch file (with Cygwin) FaeDine Programming 2 10-27-2007 04:47 PM
Bash script to process every file in current dir and sub dirs BuckRogers01 Linux - Software 3 09-06-2005 07:32 AM


All times are GMT -5. The time now is 02:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration