Python Forum
a future project for some day
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a future project for some day
#8
this is not as simple and straight forward as i had hoped. i am going to have to write some Python code for fdupes. many of my music file names cannot be passed to commands by shell without quoting (because of characters like parenthesis in the name) and fdupes offers no means to separately quote each name.

so i'll try this:
# -*- coding: utf-8 -*-
from __future__ import print_function
from subprocess import call
from sys import stderr, stdin
# do not use the -1 option on fdupes.
flist = []
for line in stdin:
    for c in '\n\r\n\r':
        if line[-1:] == c:
            line = line[:-1]
    l = len(line)
    if l < 1:
        if len(flist) < 2:
            print('flist =',repr(flist),file=stderr)
            raise Exception('fewer than 2 names in a group')
        a = flist[0]
        call(['ls','-dil',a])
        for n in flist[1:]:
            call(['ln','-fv',a,n])
            call(['ls','-dil',n])
        flist = []
    else:
        flist.append(line)
piping the output of fdupes to it.

nice ... this way worked.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
a future project for some day - by Skaperen - Apr-22-2018, 03:40 AM
RE: a future project for some day - by ljmetzger - Apr-22-2018, 01:49 PM
RE: a future project for some day - by Gribouillis - Apr-22-2018, 02:12 PM
RE: a future project for some day - by Skaperen - Apr-23-2018, 02:52 AM
RE: a future project for some day - by Skaperen - Apr-23-2018, 06:14 AM
RE: a future project for some day - by Gribouillis - Apr-23-2018, 06:39 AM
RE: a future project for some day - by Skaperen - Apr-24-2018, 02:10 AM
RE: a future project for some day - by Skaperen - Apr-24-2018, 03:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PEP 572 and Future svetlanarosemond 8 5,476 Jul-16-2018, 08:40 PM
Last Post: micseydel
  a future project: hardlink identical files Skaperen 4 4,045 Dec-18-2017, 03:38 AM
Last Post: Skaperen
  a future project: recursive file list Skaperen 0 2,260 Dec-14-2017, 03:55 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020