On Sun, 18 Feb 2018 14:44:24 +0100
[email protected] wrote:
On 02/18 01:55, Floyd Anderson wrote:
On Sun, 18 Feb 2018 13:07:33 +0100
[email protected] wrote:
> On 02/18 11:38, Stroller wrote:
> >
> > > On 18 Feb 2018, at 08:21, [email protected] wrote:
> > >
> > > when downloading files from non-UNIX sites, they often contain
> > > "poisonoys" characters like '#', ' ', ''' or that alike.
> > >
> > > With the tool 'detox' those filenames could be fixed.
> > >
> > > But detox changes the time stamp of the files, which
> > > filenames are altered (not all files, which are examined).
> > >
> > > Is there a way to either get detox not to alter the time stamp
> >
> > I think:
> >
> > tmpfile=/tmp/foo-$RANDOM
> > touch -r "$file" "$tmpfile"
> > detox "$file"
> > touch -r "$tmpfile "$file"
> > rm "$tmpfile"
> >
> > It should be trivial to patch detox to do this itself.
> >
> > Stroller
> >
> >
> >
>
> Hi Stroller,
>
> this seems to be an egg<->chicken problem.
>
> I like to wrap detox with a script, which will do you magic trick.
> Since I want to get rid of those evil characters (...) in the filename,
> which normally intercept shell processing, I want to use detox,
> which in turn will be called by a shell script in turn, to do the
> time machine magic. To do so, I need detox, to sanitize the
> filenames from the evil characters, which normally intercept.....
> .....stack overflow....recursion depth failure.....process killed.
>
> You know....
>
> I am using zsh...
>
> Any idea to get a chicken OR an egg instead of an scrambled egg with
> feathers??? ;)
Go back one step and reread the manual page. It seems to be there is an
option ‘--dry-run’ (implies ‘--verbose’) that can probably be used to store
a list of the final new file names. Afterwards you can traverse this list
with Stroller’s suggestion (slightly adopted of course).
Or you can try other tools which doesn’t use function rename() [1], e.g.
perl-rename, and therefore don’t change the last modification time.
Or you can go two steps back and save the file(s) to your like when you
download it, e.g. with curl (maybe your’re also interested in its
‘--remote-time’ option).
References:
- [1] <http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html>
--
Regards,
floyd
Hi Floyd,
the unrenamed files are the only ones with the correct timestamp.
Therefore 'touch' has to access them.
But their filenames contain the poisonous characters.
So you have to figure out why detox, that I doesn’t know and thus never
have been used, does not rename those files. Maybe because the new file
(after file name translation) already exists in directory as mentioned
in the BUGS section of the manual page. So you must ensure that all
resulting file names are unique.
A second thought is that there probably isn’t a rule for a specific
character translation, so detox won’t change those characters until you
define a rule first [1].
And the circle starts right from the beginning.
The problem arises at that moment, where I need to feed the name
of a single file what program ever, since first there is the shell...
even when calling other programs.
Here comes escaping and/or quoting into play but the glob `detox *`,
you’ve specified, should work. Can you share a sample file name with
funny characters in it?
References:
- [1] <http://detox.sourceforge.net/detox.tbl.5.html>
--
Regards,
floyd