1 |
On Sun, 18 Feb 2018 14:44:24 +0100 |
2 |
tuxic@××××××.de wrote: |
3 |
>On 02/18 01:55, Floyd Anderson wrote: |
4 |
>> On Sun, 18 Feb 2018 13:07:33 +0100 |
5 |
>> tuxic@××××××.de wrote: |
6 |
>> > On 02/18 11:38, Stroller wrote: |
7 |
>> > > |
8 |
>> > > > On 18 Feb 2018, at 08:21, tuxic@××××××.de wrote: |
9 |
>> > > > |
10 |
>> > > > when downloading files from non-UNIX sites, they often contain |
11 |
>> > > > "poisonoys" characters like '#', ' ', ''' or that alike. |
12 |
>> > > > |
13 |
>> > > > With the tool 'detox' those filenames could be fixed. |
14 |
>> > > > |
15 |
>> > > > But detox changes the time stamp of the files, which |
16 |
>> > > > filenames are altered (not all files, which are examined). |
17 |
>> > > > |
18 |
>> > > > Is there a way to either get detox not to alter the time stamp |
19 |
>> > > |
20 |
>> > > I think: |
21 |
>> > > |
22 |
>> > > tmpfile=/tmp/foo-$RANDOM |
23 |
>> > > touch -r "$file" "$tmpfile" |
24 |
>> > > detox "$file" |
25 |
>> > > touch -r "$tmpfile "$file" |
26 |
>> > > rm "$tmpfile" |
27 |
>> > > |
28 |
>> > > It should be trivial to patch detox to do this itself. |
29 |
>> > > |
30 |
>> > > Stroller |
31 |
>> > > |
32 |
>> > > |
33 |
>> > > |
34 |
>> > |
35 |
>> > Hi Stroller, |
36 |
>> > |
37 |
>> > this seems to be an egg<->chicken problem. |
38 |
>> > |
39 |
>> > I like to wrap detox with a script, which will do you magic trick. |
40 |
>> > Since I want to get rid of those evil characters (...) in the filename, |
41 |
>> > which normally intercept shell processing, I want to use detox, |
42 |
>> > which in turn will be called by a shell script in turn, to do the |
43 |
>> > time machine magic. To do so, I need detox, to sanitize the |
44 |
>> > filenames from the evil characters, which normally intercept..... |
45 |
>> > .....stack overflow....recursion depth failure.....process killed. |
46 |
>> > |
47 |
>> > You know.... |
48 |
>> > |
49 |
>> > I am using zsh... |
50 |
>> > |
51 |
>> > Any idea to get a chicken OR an egg instead of an scrambled egg with |
52 |
>> > feathers??? ;) |
53 |
>> |
54 |
>> Go back one step and reread the manual page. It seems to be there is an |
55 |
>> option ‘--dry-run’ (implies ‘--verbose’) that can probably be used to store |
56 |
>> a list of the final new file names. Afterwards you can traverse this list |
57 |
>> with Stroller’s suggestion (slightly adopted of course). |
58 |
>> |
59 |
>> Or you can try other tools which doesn’t use function rename() [1], e.g. |
60 |
>> perl-rename, and therefore don’t change the last modification time. |
61 |
>> |
62 |
>> Or you can go two steps back and save the file(s) to your like when you |
63 |
>> download it, e.g. with curl (maybe your’re also interested in its |
64 |
>> ‘--remote-time’ option). |
65 |
>> |
66 |
>> |
67 |
>> References: |
68 |
>> - [1] <http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html> |
69 |
>> |
70 |
>> |
71 |
>> -- |
72 |
>> Regards, |
73 |
>> floyd |
74 |
>> |
75 |
>> |
76 |
> |
77 |
>Hi Floyd, |
78 |
> |
79 |
>the unrenamed files are the only ones with the correct timestamp. |
80 |
>Therefore 'touch' has to access them. |
81 |
>But their filenames contain the poisonous characters. |
82 |
|
83 |
So you have to figure out why detox, that I doesn’t know and thus never |
84 |
have been used, does not rename those files. Maybe because the new file |
85 |
(after file name translation) already exists in directory as mentioned |
86 |
in the BUGS section of the manual page. So you must ensure that all |
87 |
resulting file names are unique. |
88 |
|
89 |
A second thought is that there probably isn’t a rule for a specific |
90 |
character translation, so detox won’t change those characters until you |
91 |
define a rule first [1]. |
92 |
|
93 |
>And the circle starts right from the beginning. |
94 |
>The problem arises at that moment, where I need to feed the name |
95 |
>of a single file what program ever, since first there is the shell... |
96 |
>even when calling other programs. |
97 |
|
98 |
Here comes escaping and/or quoting into play but the glob `detox *`, |
99 |
you’ve specified, should work. Can you share a sample file name with |
100 |
funny characters in it? |
101 |
|
102 |
|
103 |
References: |
104 |
- [1] <http://detox.sourceforge.net/detox.tbl.5.html> |
105 |
|
106 |
|
107 |
-- |
108 |
Regards, |
109 |
floyd |