自动命名Python脚本 - Hoblovski's Blog - 想拿Ag的蒟蒻.已经Ag滚出.
匈牙利算法的优化
RSA加密算法

自动命名Python脚本

Hoblovski posted @ 2014年8月09日 03:18 in Discussion with tags python , 1326 阅读

...退役了只好学学Python...

替换下载后的编码错误

比如 "%28C81%29 %5BKAROMIX %28karory%29%5D ....."

现在改用了一种更好的代码风格

#PROGRAM RENAMER;
import os;

Dict={
        '%5B':'[',      '%5b':'[',
        '%5D':']',      '%5d':']',
        '%28':'(',      '%29':')',
        '%26':'&',      '%2B':'+',
}

CurDir=os.getcwd()+'//';
FileList=os.listdir(CurDir);
LogFile=open('Rename.log','w');
print>>LogFile, 'Renaming Work Log';
print>>LogFile, '';
for Name in FileList:
        NewName=Name;
        for i in Dict:NewName=NewName.replace(i,Dict[i]);
        if Name!=NewName:
                print>>LogFile, 'Original: ',Name;
                print>>LogFile, 'Current:  ',NewName;
                print>>LogFile, '';
                os.rename(CurDir+Name,CurDir+NewName);
print 'Successful Renaming work. Press Any Key to Exit';
os.system('pause>nul');
exit();

批量加前缀和后缀

#PROGRAM RENAMER;
import os;

Prefix='[CASO&Sumisora][Gochiusa][';
Suffix='][GB][720p]';
CurDir=os.getcwd()+'//';
FileList=os.listdir(CurDir);
for Name in FileList:
        NewName=Prefix+Name;
        for i in reversed(range(len(NewName))):
                if NewName[i]=='.':
                        NewName=NewName[0:i]+Suffix+NewName[i:len(NewName)];
                        break;
        else:
                NewName=NewName+Suffix;
        os.rename(CurDir+Name,CurDir+NewName);
print 'Successful Renaming work. Press Any Key to Exit';
os.system('pause>nul');
exit();
Avatar_small
West Bengal 10th Exa 说:
2021年10月12日 21:29

The state class 6th, 7th, 8th, and 9th standard of high school level Bengali medium, English medium, Hindi medium, Urdu medium, and other medium students of WBBSE have been announced. Every year, West Bengal 10th Exam Pattern 2022 the WB Kolkata board releases the WB Madhyamik Shiksha Model Question Bank 2022 with suggested answers for all general and vocational course students in grades VI to IX, and this year was no exception.

Avatar_small
ICSE 10th Syllabus 2 说:
2022年5月02日 19:12

ICSE 10th Latest Syllabus 2023 Releasing on 15th May 2023. Candidates who have written the SSC Exam in the month of April will be waiting for the CISCE Board Class 10th Syllabus 2023 Download ICSE Xth ICSE 10th Syllabus 2023 Exam Score Card in the PDF Format from the link attached below. Download ICSE 10th Syllabus 2023

Avatar_small
Alyssa 说:
2023年1月01日 00:18

Python scripts can be automatically named using the __name__ variable. This CBD products variable is set to the name of the script when it is executed. For example, if the script is named "script.py", the __name__ variable will be set to "script".

Avatar_small
12thmodelpapers.in 说:
2023年5月23日 17:20

Initiative of professional writers who have banded together to provide devoted news coverage of current events in India. Our team is made up of professional writers and citizen journalists with a wide range of journalism interests who are passionate about reporting Education Updates with transparency in the general12thmodelpapers.in public interest.Our reporting team plans to provide the Education & Recruitment Update for all age groups and to present the actual picture of recent events through inside coverage. Our goal is to meet the needs of people of all ages by publishing news categorised as General, Political, Crime, Sports, Entertainment, Education, and World News.

Avatar_small
edpost.in 说:
2023年6月28日 17:31

edpost is a initiative of professional writers who have come together for dedicated news coverage of latest happenings around the country (India). Our team comprises of professional writers & citizen edpost.in journalists with diverse range of interest in Journalism who are passionate about publishing the Education Updates with transparency in general public interest.

Avatar_small
Robot 说:
2023年7月27日 16:08

Automatically naming Python scripts streamlines the coding process, ensuring organized and easily identifiable files, just as you can streamline your academic pursuit with Masters Dissertation Proposal Help, gaining expert guidance to create a compelling research proposal that lays the foundation for your master's study. Embrace efficiency in coding while securing professional support for your scholarly endeavors.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter