You are not logged in.
Hello everybody,
I used to use 'scribes' for txt files but now it's unmaintained for more than a year.
I have a folder of hundered of txt files that look like this 'browse_reddit_at_work_pretending_you_are_doing_something_important_2019_04-24_210459'.
In fact 'scribes' initially saved them as 'browse reddit at work pretending you are doing something important (2019 04-24 210459)'
I have a script to modify the titles a bit but the timestamps remain.
How to remove all the timestamps at the end of those files?
Thank you in advance!
p.s. I have no programming skills. The script I mentioned I have is from Arch forum.
Last edited by amaro (2020-10-23 12:18:41)
Offline
If you don't mind use perl parallel that is pretty fast. And how do you keep a unique file name without timestamps? This little bash/perl function assume you have unique filenames.
# pacman -S parallel
timestamps ()
{
local name='something_important_2019_04-24_210459';
local dir=${1:?[directory]};
[[ -d $dir ]] || return 1;
/usr/sbin/perl - "${dir}" <<'PERLMV' |
use v5.32.0;
use warnings;
use File::Find;
my @Files;
my ($dir) = @ARGV;
my ($j,$source,$target) = (0,"","");
sub insert
{
if(-d){
return;
}else{
$source = "$File::Find::name";
$target = $source =~ s;(.*)_\d+_\d\d-\d\d_\d+;$1;r;
$Files[$j++] = "mv $source $target\n";
}
}
find(\&insert,$dir);
say @Files
PERLMV
/usr/sbin/parallel -j 4 --will-cite
}Last edited by solskog (2020-10-23 08:00:22)
Offline
What you want to do is called a "batch rename" or a "bulk rename". Look up both terms in the pacman repos and the AUR. There must be one tool that meets your needs.
However, this would be the perfect opportunity to learn some shell scripting.
Offline
thunar file manager has a good batch renamer built in:
https://docs.xfce.org/xfce/thunar/bulk-renamer/start
Offline
Easily doable in python too.
Offline
Thank you, guys!
Used Thunar's renamer as jonno2002 suggested. Worked fine.
(Have never used it before)
Offline