Support
Forums

Re: Changing date format in filenames in Linux

Hi,
If your feeling adventurous and are willing to stray beyond the shell, how about;

[code]#!/usr/bin/env python3
 
from sys import argv
from shutil import move
argv.pop(0)
 
try:
    for name in argv:
        path = name.split("/")
        file = path.pop()
        parts = file.replace('.','-').split('-')
        ext = parts.pop()
        parts.reverse()
        path.append('-'.join(parts) + '.' + ext)
        rename = '/'.join(path)
        move(name, rename)
        print(f'renamed "{na...
Hi,
If your feeling adventurous and are willing to stray beyond the shell, how about;

[code]#!/usr/bin/env python3
 
from sys import argv
from shutil import move
argv.pop(0)
 
try:
    for name in argv:
        path = name.split("/")
        file = path.pop()
        parts = file.replace('.','-').split('-')
        ext = parts.pop()
        parts.reverse()
        path.append('-'.join(parts) + '.' + ext)
        rename = '/'.join(path)
        move(name, rename)
        print(f'renamed "{na...