Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:51:34+00:00 2026-06-17T13:51:34+00:00

I found a tool to find duplicate files, and now I’m ready to delete

  • 0

I found a tool to find duplicate files, and now I’m ready to delete the duplicates. I stared at the format of the output file for a bit, and came up with this script.

#!/usr/bin/env ruby 

contents = File.open('fdupes-result', 'rb') { |f| f.read }
duplicates = contents.split("\n\n")

duplicates.each do |set|
  list = set.split("\n").reverse
  list.drop(1).each do |filename|
      # print "rm #{filename}"
      %x[ rm #{filename} ]
  end
end

The commented print statement is what I used to test the thing non-destructively, and it seemed to work great. But when I added the %x command I started getting

sh: 1: Syntax error: "(" unexpected

I didn’t know what was happening, until I realized that the file has names like /media/LilGalactus/music/Robert Johnson - Complete Recordings/Robert Johnson - The Complete Recordings (Disc2of2)[EAC-FLAC](oan)/s.gif — i.e., my data is full of unescaped spaces, brackets, and the like. For about 30 seconds I considered escaping the characters by using vim commands like :s/\(/\\\(/g and I think the limitations of that method are pretty obvious. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:51:35+00:00Added an answer on June 17, 2026 at 1:51 pm

    Instead of escaping them just add double-quotes like this: %x[ rm "#{filename}" ]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found great tool for Image slide show as in the link below http://thiagosf.net/projects/jquery/skitter/
I am using the jQuery spinner tool found here: http://btburnett.com/spinner/example/example.html When I try using
I've recently found this blog entry on a tool that writes XSS attacks directly
I look for tool which can compress JavaScript source code. I found some web
I want to learn zend without using the zend tool. I've found some good
Possible Duplicate: Resharper string.format shortcut In our large code base, unfortunately there are a
Possible Duplicate: Are there any free cmd-line scripts which can re-format PHP source-code? I've
I was hoping to be able to find a tool,application or script that takes
found a lot of questions involving finding duplicates in two columns : i.e. MS
I've been dealing with ebooks lately, and found it quite hard to quickly find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.