Skip to content

Rename videos in bulk - linux commands

Unsolved Tips
12 2 2.0k 1
  • Managing videos is a big hassle. To follow the 3-2-1 backup strategy, I want to keep a copy of my videos online. After some research, I found that GoPro is the easiest and cheapest option, costing around $25 or $50 per year for unlimited footage. (i have 20TB videos)Now, the goal is to upload all my files to GoPro.

    GoPro doesn’t provide a drive-like system, so I need to upload files directly to the GoPro website. Before doing that, I want to add folder names to the file names using a Linux command to rename them. so i can use their search to find files later.

    All my videos are stored in Synology Drive in the following format:

    Videos/date/filename1.mp4
    

    I only want to rename the MP4 files to have the format date-filename1.mp4. How can I do this using a command targeting all directory and subdirectories?

  • Managing videos is a big hassle. To follow the 3-2-1 backup strategy, I want to keep a copy of my videos online. After some research, I found that GoPro is the easiest and cheapest option, costing around $25 or $50 per year for unlimited footage. (i have 20TB videos)Now, the goal is to upload all my files to GoPro.

    GoPro doesn’t provide a drive-like system, so I need to upload files directly to the GoPro website. Before doing that, I want to add folder names to the file names using a Linux command to rename them. so i can use their search to find files later.

    All my videos are stored in Synology Drive in the following format:

    Videos/date/filename1.mp4
    

    I only want to rename the MP4 files to have the format date-filename1.mp4. How can I do this using a command targeting all directory and subdirectories?

    @Hari I don’t think the GoPro subscription is going to cut it here to be honest. The Web client will have limits and likely upload speeds will be incredibly slow.

    I addition, web uploading always seem to lack the ability to resume at last failure etc like your can get with SFTP and uploading 20Tb of videos will literally take forever.

    20Tb of videos seems excessive also. You’ll struggle to find any storage provider who will give you that level of storage, and GoPro are likely to have fair usage limits what will prevent you from uploading that sort of volume.

    The script you’re looking for in terms of preparing each upload (rename and move into directory) isn’t difficult, but do you know for sure that GoPro actually support this?

  • @Hari I don’t think the GoPro subscription is going to cut it here to be honest. The Web client will have limits and likely upload speeds will be incredibly slow.

    I addition, web uploading always seem to lack the ability to resume at last failure etc like your can get with SFTP and uploading 20Tb of videos will literally take forever.

    20Tb of videos seems excessive also. You’ll struggle to find any storage provider who will give you that level of storage, and GoPro are likely to have fair usage limits what will prevent you from uploading that sort of volume.

    The script you’re looking for in terms of preparing each upload (rename and move into directory) isn’t difficult, but do you know for sure that GoPro actually support this?

    @phenomlab i am looking for a linux command i will be running it on my synology to add directory name to the files, then i will be uploading manually 50 videos per day. i have the account and it is free why not trying for its full potential 😄

  • @phenomlab i am looking for a linux command i will be running it on my synology to add directory name to the files, then i will be uploading manually 50 videos per day. i have the account and it is free why not trying for its full potential 😄

    @Hari more than happy for you to try it, although I think it’s going to be rate limited and will go against their fair usage policy.

  • Could you please help me with a linux command to do rename files?

  • Could you please help me with a linux command to do rename files?

    @Hari Of course, but I need a bit more detail around how you want to name the directories you mentioned.

    As a starting point, you could so something like this

    You can use the find command along with bash to achieve this. Here’s an example command:

    find /path/to/root/directory -type f -name "*.mp4" -exec bash -c 'for file; do mv "$file" "$(date +"%Y%m%d")-${file##*/}"; done' bash {} +
    

    This command will find all .mp4 files under the specified root directory and its subdirectories, then rename them to the format date-filename1.mp4, where the date is in the format YYYYMMDD.

    Here’s a breakdown of what will happen

    find /path/to/root/directory -type f -name "*.mp4"
    
    • Finds all files with the extension .mp4 under the specified root directory.
    -exec bash -c '...' bash {} +
    
    • Executes the specified bash command for each found file.
    'for file; do mv "$file" "$(date +"%Y%m%d")-${file##*/}"; done'
    

    This bash script renames each file by appending the date and a hyphen to the original filename.

    Make sure to replace /path/to/root/directory with the actual path to your root directory.

  • @Hari Of course, but I need a bit more detail around how you want to name the directories you mentioned.

    As a starting point, you could so something like this

    You can use the find command along with bash to achieve this. Here’s an example command:

    find /path/to/root/directory -type f -name "*.mp4" -exec bash -c 'for file; do mv "$file" "$(date +"%Y%m%d")-${file##*/}"; done' bash {} +
    

    This command will find all .mp4 files under the specified root directory and its subdirectories, then rename them to the format date-filename1.mp4, where the date is in the format YYYYMMDD.

    Here’s a breakdown of what will happen

    find /path/to/root/directory -type f -name "*.mp4"
    
    • Finds all files with the extension .mp4 under the specified root directory.
    -exec bash -c '...' bash {} +
    
    • Executes the specified bash command for each found file.
    'for file; do mv "$file" "$(date +"%Y%m%d")-${file##*/}"; done'
    

    This bash script renames each file by appending the date and a hyphen to the original filename.

    Make sure to replace /path/to/root/directory with the actual path to your root directory.

    @phenomlab I’m trying to put the folder name at the beginning of each file. I found out about this by looking at a few renaming programs on Windows.

    I want to rename the files like this:

    Website/FolderName/file1.mp4
    Website/FolderName2/file10.mp4

    expected output targeting directories and sub directories:

    FolderName2-file10.mp4
    FolderName-file1.mp4
    

    I want the file names to be the folder name plus the file name, focusing on MP4 files.

    351cef3f-df60-4620-b146-2e5541bad80c-image.png

    9f71efa6-7ffc-4417-a418-5e4e73270b00-image.png

  • @phenomlab I’m trying to put the folder name at the beginning of each file. I found out about this by looking at a few renaming programs on Windows.

    I want to rename the files like this:

    Website/FolderName/file1.mp4
    Website/FolderName2/file10.mp4

    expected output targeting directories and sub directories:

    FolderName2-file10.mp4
    FolderName-file1.mp4
    

    I want the file names to be the folder name plus the file name, focusing on MP4 files.

    351cef3f-df60-4620-b146-2e5541bad80c-image.png

    9f71efa6-7ffc-4417-a418-5e4e73270b00-image.png

    @Hari i’m slightly confused. Are you looking to do this from Windows, or from Linux? The post below seems to point towards Linux, hence my response

    33dc5fff-395d-4131-8929-5c0ba0939a64-image.png

  • @Hari i’m slightly confused. Are you looking to do this from Windows, or from Linux? The post below seems to point towards Linux, hence my response

    33dc5fff-395d-4131-8929-5c0ba0939a64-image.png

    @phenomlab i am sharing examples from a windows machine and i am supposed to run these commands on Synology nas

  • @phenomlab i am sharing examples from a windows machine and i am supposed to run these commands on Synology nas

    @Hari How do you connect to the Synology? Is this via SMB or mapped drive? I’m thinking it may be easier to go down this route and use a batch copy/rename application in Windows.

  • @Hari How do you connect to the Synology? Is this via SMB or mapped drive? I’m thinking it may be easier to go down this route and use a batch copy/rename application in Windows.

    @phenomlab i think i am connected using SMB

    is this the batch rename software? https://www.bulkrenameutility.co.uk/

    21df3f50-d8c8-493a-a52f-18b0395b3852-image.png

  • @phenomlab i think i am connected using SMB

    is this the batch rename software? https://www.bulkrenameutility.co.uk/

    21df3f50-d8c8-493a-a52f-18b0395b3852-image.png

    @Hari Yes, that’s one (of many) I would recommend. It’s going to be easier to do this under Windows and the fact that you are already connected using SMB is a huge plus.


Related Topics
  • Arch Linux | Reflector

    Linux arch linux pacman reflector updates
    4
    4 Votes
    4 Posts
    1k Views
    I have another update for reflector that I just figured out. You will want to edit the following file and add details to make sure that every time it updates the mirror list, it is grabbing them from your country and I grab 10 and sort them by rate. This will ensure that your mirrorlist isn’t getting populated with links from other countries which can slow down you downloads. sudo nano /etc/xdg/reflector/reflector.conf This is what the file looks like. # Reflector configuration file for the systemd service. # # Empty lines and lines beginning with "#" are ignored. All other lines should # contain valid reflector command-line arguments. The lines are parsed with # Python's shlex modules so standard shell syntax should work. All arguments are # collected into a single argument list. # # See "reflector --help" for details. # Recommended Options # Set the output path where the mirrorlist will be saved (--save). --save /etc/pacman.d/mirrorlist # Select the transfer protocol (--protocol). --protocol https # Select the country (--country). # Consult the list of available countries with "reflector --list-countries" and # select the countries nearest to you or the ones that you trust. For example: --country US # Use only the most recently synchronized mirrors (--latest). --latest 10 # Sort the mirrors by synchronization time (--sort). --sort rate Here are the different flag options that you can change or add to this file. I found this on google by searching arch linux reflector flags. Filtering Options (What to find) --country <CODE/Name>: Selects mirrors from specific countries (e.g., US, France,Germany). Use {Link: reflector --list-countries https://archlinux.org/mirrors/status/}, for a full list. --protocol <http|https>: Filters for HTTP or HTTPS mirrors. --age <hours>: Only includes mirrors synced within the last X hours (e.g., --age 12). --delay <hours>: Limits to mirrors with a reported sync delay of X hours or less (e.g., --delay 0.25 for 15 mins). --latest <N>: Limits results to the top N newest mirrors. Sorting Options (How to order) --sort rate: Sorts by download speed (requires testing, can be slow). --sort age: Sorts by most recently synced. --sort score: Sorts by overall score. --sort country: Sorts by country, useful with multiple countries. Output Options (Where to put it) --save <path>: Writes the filtered/sorted list to a file (e.g., /etc/pacman.d/mirrorlist). --verbose or -v: Shows detailed progress and mirror info.
  • Windows 10 End of Life

    General windows linux arch end of life
    10
    2 Votes
    10 Posts
    1k Views
    @phenomlab this looks very nice as well. It is nice that they keep the KDE Neon a rolling release so you will get those updated apps even though Ubuntu isn’t a rolling release. Is it a rolling distro? KDE neon is rolling for KDE software. The Ubuntu base OS is not, but certain packages will be updated as needed to support KDE software requiring newer library versions than what is provided by Ubuntu. Apps from the main repositories are not rolling either, and therefore can be up to two years old. Users are encouraged not to use them, and to instead get apps from Snap or Flatpak using KDE’s Discover app store. In neon, Discover is set up to only show apps from these sources, filtering out apps from the repositories.
  • Linux on a Stick

    Linux linux usb arch
    29
    16 Votes
    29 Posts
    3k Views
    @DownPW I haven’t tried either of those, I am sure they run fast as well. Linux is so versatile it is awesome!
  • Arch Server Progress

    Chitchat arch linux server web server
    52
    26 Votes
    52 Posts
    8k Views
    @phenomlab said in Arch Server Progress: PITA LOL yes for sure!!
  • 1 Votes
    3 Posts
    917 Views
    @Panda said in Wasting time on a system that hangs on boot: Why do you prefer to use KDE Linux distro, over say Ubuntu? A matter of taste really. I’ve tried pretty much every Linux distro out there over the years, and whilst I started with Ubuntu, I used Linux mint for a long time also. All of them are Debian backed anyway I guess I feel in love with KDE (Neon) because of the amount of effort they’d gone to in relation to the UI. I agree about the lead and the OS statement which is why I suspect that Windows simply ignored it (although the Device also worked fine there, so it clearly wasn’t that faulty)
  • Killing Linux Zombie Processes

    Tips zombie linux
    3
    7
    2 Votes
    3 Posts
    968 Views
    @DownPW odd indeed. Looks like it’s spawning, immediately dying, then spawning again.
  • Linux vs Windows - who wins ?

    Blog windows linux
    8
    4 Votes
    8 Posts
    1k Views
    @phenomlab LOL ah yes, I remember all of that. The good ole days!
  • Environment Variables

    Solved Linux
    8
    1
    1 Votes
    8 Posts
    2k Views
    @madchatthew great you got this to work ! Thanks for the update.