Skip to content
Advertisement

Tag: rename

Rename part of filename using regex

I have a bunch of files where there is additional information in square brackets. I would like to rename them by removing that section. For example: Want to rename to: I tried playing with regex (and using the rename command) but without success. Does anybody know a way to have the rename command strip of only the part of “

Renaming long file names in bulk

I have file names like: I want something like: Are there good ways to rename these files in linux? Answer You could try using a loop to extract the important part of the filename: This will simply give you a new list of filenames. You can then move them: To break this down a little: loop over the *.gz files

Add id to the downloaded youtube playlist

I’ve downloaded a youtube playlist with youtube-dl is there any way i can rename the files i’ve downloaded to the appended id of the file in playlist. e.g. now xyz.mp4 abc.mkv want 1 – xyz.mp4 2 – abc.mkv (which is according to the number in the youtube playlist) Answer If the files are sortable by date (check if the following

Linux batch rename files

I am going to rename image files and pdf files in a folder in Linux. It should be recursively as some files are in sub-sub folder. Current file name pattern is like: My goal pattern is In a short, I want to remove everything before -NumberString-, and keep everything afterwards (includes the NumberString). Can anyone help? Thanks a lot Answer

How to uppercase file name but exclude extension

Is it possible to use rename to uppercase a file but exclude its extension? ie: I want to rename the file foo_bar.ext to FOO_BAR.ext I tried with rename ‘y/a-z/A-Z/’ foo_bar.ext, but the whole file (including extension) gets uppercased FOO_BAR.EXT Answer You are asking rename to convert all the instances of [a-z] to [A-Z]. Instead, capture the desired string into a

Is rename() without fsync() safe?

Is it safe to call rename(tmppath, path) without calling fsync(tmppath_fd) first? I want the path to always point to a complete file. I care mainly about Ext4. Is the rename() promised to be safe in all future Linux kernel versions? A usage example in Python: Answer No. Look at libeatmydata, and this presentation: Eat My Data: How Everybody Gets File

Advertisement