-
-
Save t1anchen/4652893 to your computer and use it in GitHub Desktop.
#!/usr/bin/python | |
import os | |
import sys | |
import getopt | |
import re | |
import os.path | |
def main(): | |
for dirpath, dirnames, filenames in os.walk(sys.argv[1]): | |
# for i in os.walk(sys.argv[1]): | |
# for i in filenames: | |
# new_filename = re.sub(r' ', r'.', filename) | |
# full_filename = os.path.join(dirpath, filename) | |
# if re.search(r' ', full_filename) != None: | |
# new_full_filename = re.sub(r' ',r'.',full_filename) | |
# os.rename(full_filename, new_full_filename) | |
# if full_filename != new_full_filename: | |
# print full_filename + " -> " + new_full_filename | |
for filename in filenames: | |
new_filename = re.sub(r' ', r'.', filename) | |
if new_filename != filename: | |
old_full_filename = os.path.join(dirpath, filename) | |
new_full_filename = os.path.join(dirpath, new_filename) | |
os.rename(old_full_filename, new_full_filename) | |
print 'File: ', old_full_filename, ' -> ', new_full_filename | |
for dirname in dirnames: | |
new_dirname = re.sub(r' ', r'.', dirname) | |
if new_dirname != dirname: | |
old_full_dirname = os.path.join(dirpath, dirname) | |
new_full_dirname = os.path.join(dirpath, new_dirname) | |
os.rename(old_full_dirname, new_full_dirname) | |
print 'Directory: ', old_full_dirname, ' -> ', new_full_dirname | |
if __name__ == "__main__": | |
main() | |
I've posted another version https://gist.github.com/t1anchen/7e03f2650b653d2f29ce60d92ca797aa . You might have a look if you're interested in.
is this possible to use this script as postprocessing to copy and change name of name.pl.srt file to name.1.srt
variables for bazarr python subs downloader are:
{{directory}}
The full path of the episode file parent directory.
{{episode}}
The full path of the episode file.
{{episode_name}}
The filename of the episode without parent directory or extension.
{{subtitles}}
The full path of the subtitles file.
{{subtitles_language}}
The language of the subtitles file.
{{subtitles_language_code2}}
The 2-letter ISO-639 language code of the subtitles language.
{{subtitles_language_code3}}
The 3-letter ISO-639 language code of the subtitles language.
i want to get something like
bash command
for f in "{{subtitles}}"/*.pl.srt; do cp "$f" "${f%.pl.srt}.1.srt" ; done
but cant figure it out
any help please
is this possible to use this script as postprocessing to copy and change name of name.pl.srt file to name.1.srt
variables for bazarr python subs downloader are:{{directory}}
The full path of the episode file parent directory.
{{episode}}
The full path of the episode file.
{{episode_name}}
The filename of the episode without parent directory or extension.
{{subtitles}}
The full path of the subtitles file.
{{subtitles_language}}
The language of the subtitles file.
{{subtitles_language_code2}}
The 2-letter ISO-639 language code of the subtitles language.
{{subtitles_language_code3}}
The 3-letter ISO-639 language code of the subtitles language.
i want to get something like
bash command
for f in "{{subtitles}}"/*.pl.srt; do cp "$f" "${f%.pl.srt}.1.srt" ; done
but cant figure it out
any help please
Not sure if I understand it correctly. Do you mean you want to copy the file <directory>/<episode_name>.<ISO-639 2-letter>.srt
to <directory>/<episode_name>.1.srt
?
Yes, thank You i finally used very similiar string to rename those files
thanks for it. i littly modifed and used that.