I got tired of replacing the above, so I wrote this.
replace-dots.cmd
Cheers.Code:@echo off :: Replace all the dots in a file name. :: "How.to.milk.a.moo.cow.mp4" becomes "How to milk a moo cow.mp4" for %%a in (*.avi, *.mp4, *.mkv, *.srt, *.aac, *.mp3) do call :process "%%a" goto :end :process setlocal set ext=%~x1 set tmp1=%~1 set tmp2=%tmp1:.= % set tmp3=%tmp2: = % if "%ext%"==".avi" set tmp4=%tmp3: avi=.avi% if "%ext%"==".mp4" set tmp4=%tmp3: mp4=.mp4% if "%ext%"==".mkv" set tmp4=%tmp3: mkv=.mkv% if "%ext%"==".srt" set tmp4=%tmp3: srt=.srt% if "%ext%"==".aac" set tmp4=%tmp3: aac=.aac% if "%ext%"==".mp3" set tmp4=%tmp3: mp3=.mp3% ren "%~1" "%tmp4%" endlocal goto :eof :end
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 6 of 6
Thread
-
Last edited by pcspeak; 19th Apr 2024 at 19:46.
-
Not wanting to dispute simple window batch script posted, it is simple and does what it suppose to, fast and simple.
Just bringing attention to cross platform python, where a simple graphical gui could be used to confirm renaming. Arguments could be files or a directory (files in it will be renamed) or no argument, just double clicking a python file (current directory will be used for renaming).
All with pop up to confirm renaming (only once for all arguments if more arguments).
Code:""" Replace all the dots in a file name. "How.to.milk.a.moo.cow.mp4" becomes "How to milk a moo cow.mp4" """ import sys import os from pathlib import Path import tkinter from tkinter import messagebox CONFIRM = [True] def rename(path): confirm() #removes dots from path name path = Path(path) stem = path.stem new_stem = stem.replace(".", " ") new_path = path.with_name(f"{new_stem}{path.suffix}") path.rename(new_path) def rename_directory_paths(directory): EXTENSIONS = {".avi", ".mp4", ".mkv", ".srt", ".aac", ".mp3"} directory = Path(directory) if not directory.is_dir(): raise ValueError(f"Not a directory: {directory}") for path in directory.iterdir(): if path.suffix in EXTENSIONS: rename(path) def rename_paths(paths): for path in paths: rename(path) def confirm(): if not CONFIRM[0]: return #asks if wanting renaming, one time only for all arguments root = tkinter.Tk() root.withdraw() result = messagebox.askquestion('Rename dots to spaces in filenames', 'Are you sure to rename filenames?') if result == "yes": CONFIRM[0] = False root.destroy() elif result == "no": root.destroy() root.mainloop() if result == "no": exit() if __name__ == "__main__": """ Usage: python remove_dots.py file.1.mp3 file.2.mp4 ... or python remove_dots.py C:/my_dir or python remove_dots.py # will rename fles in current directory """ args = sys.argv[1:] if args: if Path(args[0]).is_dir(): directory = args[0] rename_directory_paths(directory) else: rename_paths(args) else: directory = Path('.') rename_directory_paths(directory)
-
@pcspeak...
Don't have an issue with dots. Maybe that's a Linux thing. In Windows it is underscores that I'm always tidying up. This will save quite a bit of time...Thanks -
This should work.
Code:@echo off :: Replace all the dots in a file name. :: "How.to.milk.a.moo.cow.mp4" becomes "How to milk a moo cow.mp4" for /r %%a in (*.avi, *.mp4, *.mkv, *.srt, *.aac, *.mp3) do call :process "%%a" goto :end :process setlocal set ext=%~x1 set tmp1=%~nx1 set tmp2=%tmp1:.= % set tmp3=%tmp2: = % if "%ext%"==".avi" set tmp4=%tmp3: avi=.avi% if "%ext%"==".mp4" set tmp4=%tmp3: mp4=.mp4% if "%ext%"==".mkv" set tmp4=%tmp3: mkv=.mkv% if "%ext%"==".srt" set tmp4=%tmp3: srt=.srt% if "%ext%"==".aac" set tmp4=%tmp3: aac=.aac% if "%ext%"==".mp3" set tmp4=%tmp3: mp3=.mp3% ren "%~dpnx1" "%tmp4%" endlocal goto :eof :end
Last edited by pcspeak; 20th Apr 2024 at 19:12.
-
Great work, thank you very much - it does work.
I removed the dots from a whole bunch of files in a few seconds.
Similar Threads
-
Leaving Thumb Drive Plugged In For Long Periods Of Time
By cornemuse in forum Off topicReplies: 3Last Post: 23rd Apr 2024, 13:59 -
Are periods used in avisynth scripts substitutes for line breaks?
By LaserBones in forum Newbie / General discussionsReplies: 6Last Post: 15th Sep 2023, 02:02 -
virtualdub stops capturing when the file gets large
By amisha in forum CapturingReplies: 5Last Post: 15th Mar 2021, 14:47 -
Annoying Dots in the image
By Smart Jason in forum DVD RippingReplies: 11Last Post: 16th Feb 2021, 11:23 -
Adding numbers to output file names with YouTube-DLG
By Hakunamatata67 in forum Video Streaming DownloadingReplies: 6Last Post: 18th Jun 2020, 03:32