-
Notifications
You must be signed in to change notification settings - Fork 0
/
testoo2.txt
2 lines (2 loc) · 16.6 KB
/
testoo2.txt
1
2
document.write('<link rel="stylesheet" href="https://github.githubassets.com/assets/gist-embed-230e526d9a70.css">')
document.write('<div id=\"gist498412\" class=\"gist\">\n <div class=\"gist-file\" translate=\"no\">\n <div class=\"gist-data\">\n <div class=\"js-gist-file-update-container js-task-list-container file-box\">\n <div id=\"file-movie-file-rename\" class=\"file my-2\">\n \n <div itemprop=\"text\" class=\"Box-body p-0 blob-wrapper data type-text \">\n\n \n<div class=\"js-check-bidi js-blob-code-container blob-code-content\">\n\n <template class=\"js-file-alert-template\">\n <div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n <svg aria-hidden=\"true\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n <path fill-rule=\"evenodd\" d=\"M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z\"><\/path>\n<\/svg>\n \n <span>\n This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.\n <a href=\"https://github.co/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a>\n <\/span>\n\n\n <div data-view-component=\"true\" class=\"flash-action\"> <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\"> Show hidden characters\n<\/a>\n<\/div>\n<\/div><\/template>\n<template class=\"js-line-alert-template\">\n <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\">\n <svg aria-hidden=\"true\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n <path fill-rule=\"evenodd\" d=\"M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z\"><\/path>\n<\/svg>\n<\/span><\/template>\n\n <table data-hpc class=\"highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file\" data-tab-size=\"8\" data-paste-markdown-skip data-tagsearch-lang=\"\" data-tagsearch-path=\"movie file rename\">\n <tr>\n <td id=\"file-movie-file-rename-L1\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n <td id=\"file-movie-file-rename-LC1\" class=\"blob-code blob-code-inner js-file-line\">require 'fileutils'<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L2\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n <td id=\"file-movie-file-rename-LC2\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L3\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n <td id=\"file-movie-file-rename-LC3\" class=\"blob-code blob-code-inner js-file-line\"># [chinesename].englishname.garbage.ext => abc - [chinesename].ext<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L4\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n <td id=\"file-movie-file-rename-LC4\" class=\"blob-code blob-code-inner js-file-line\">def rename1(path)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L5\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n <td id=\"file-movie-file-rename-LC5\" class=\"blob-code blob-code-inner js-file-line\"> files = Dir["#{path}/*"].each {|file|<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L6\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n <td id=\"file-movie-file-rename-LC6\" class=\"blob-code blob-code-inner js-file-line\"> filename = file.split('/')[-1]<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L7\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n <td id=\"file-movie-file-rename-LC7\" class=\"blob-code blob-code-inner js-file-line\"> next if filename !~ /^\\[/<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L8\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n <td id=\"file-movie-file-rename-LC8\" class=\"blob-code blob-code-inner js-file-line\"> if filename =~ /(\\[.+\\]\\.?)(.*)(\\.[a-z]+)/<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L9\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n <td id=\"file-movie-file-rename-LC9\" class=\"blob-code blob-code-inner js-file-line\"> chinesename = \$1<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L10\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n <td id=\"file-movie-file-rename-LC10\" class=\"blob-code blob-code-inner js-file-line\"> ext = \$3<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L11\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"11\"><\/td>\n <td id=\"file-movie-file-rename-LC11\" class=\"blob-code blob-code-inner js-file-line\"> remain = \$2<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L12\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"12\"><\/td>\n <td id=\"file-movie-file-rename-LC12\" class=\"blob-code blob-code-inner js-file-line\"> chinesename.gsub!(".",'')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L13\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"13\"><\/td>\n <td id=\"file-movie-file-rename-LC13\" class=\"blob-code blob-code-inner js-file-line\"> remain.gsub!(/-.+-/,'')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L14\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"14\"><\/td>\n <td id=\"file-movie-file-rename-LC14\" class=\"blob-code blob-code-inner js-file-line\"> remain.gsub!(/.(DVD|YYeTs|owenshen|\\d\\d\\d\\d|jhlw).*\$/,'')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L15\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"15\"><\/td>\n <td id=\"file-movie-file-rename-LC15\" class=\"blob-code blob-code-inner js-file-line\"> remain.gsub!('.', ' ')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L16\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"16\"><\/td>\n <td id=\"file-movie-file-rename-LC16\" class=\"blob-code blob-code-inner js-file-line\"> newfilename = remain + ' - ' + chinesename + ext<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L17\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"17\"><\/td>\n <td id=\"file-movie-file-rename-LC17\" class=\"blob-code blob-code-inner js-file-line\"> newfilepath = File.join(path, newfilename)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L18\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"18\"><\/td>\n <td id=\"file-movie-file-rename-LC18\" class=\"blob-code blob-code-inner js-file-line\"> FileUtils.mv file, newfilepath<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L19\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"19\"><\/td>\n <td id=\"file-movie-file-rename-LC19\" class=\"blob-code blob-code-inner js-file-line\"> end<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L20\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"20\"><\/td>\n <td id=\"file-movie-file-rename-LC20\" class=\"blob-code blob-code-inner js-file-line\"> } <\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L21\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"21\"><\/td>\n <td id=\"file-movie-file-rename-LC21\" class=\"blob-code blob-code-inner js-file-line\">end<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L22\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"22\"><\/td>\n <td id=\"file-movie-file-rename-LC22\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L23\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"23\"><\/td>\n <td id=\"file-movie-file-rename-LC23\" class=\"blob-code blob-code-inner js-file-line\">def rename2(path)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L24\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"24\"><\/td>\n <td id=\"file-movie-file-rename-LC24\" class=\"blob-code blob-code-inner js-file-line\"> Dir["#{path}/*.rmvb"].each {|file|<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L25\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"25\"><\/td>\n <td id=\"file-movie-file-rename-LC25\" class=\"blob-code blob-code-inner js-file-line\"> if file =~ /(.+)(\\.(19|20)\\d\\d\\.*)/<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L26\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"26\"><\/td>\n <td id=\"file-movie-file-rename-LC26\" class=\"blob-code blob-code-inner js-file-line\"> name = \$1 + ".rmvb"<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L27\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"27\"><\/td>\n <td id=\"file-movie-file-rename-LC27\" class=\"blob-code blob-code-inner js-file-line\"> FileUtils.mv file, name<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L28\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"28\"><\/td>\n <td id=\"file-movie-file-rename-LC28\" class=\"blob-code blob-code-inner js-file-line\"> end<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L29\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"29\"><\/td>\n <td id=\"file-movie-file-rename-LC29\" class=\"blob-code blob-code-inner js-file-line\"> } <\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L30\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"30\"><\/td>\n <td id=\"file-movie-file-rename-LC30\" class=\"blob-code blob-code-inner js-file-line\">end<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L31\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"31\"><\/td>\n <td id=\"file-movie-file-rename-LC31\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L32\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"32\"><\/td>\n <td id=\"file-movie-file-rename-LC32\" class=\"blob-code blob-code-inner js-file-line\">def rename3(path)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L33\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"33\"><\/td>\n <td id=\"file-movie-file-rename-LC33\" class=\"blob-code blob-code-inner js-file-line\"> Dir["#{path}/*.rmvb"].each {|file|<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L34\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"34\"><\/td>\n <td id=\"file-movie-file-rename-LC34\" class=\"blob-code blob-code-inner js-file-line\"> filename = file.split('/')[-1]<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L35\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"35\"><\/td>\n <td id=\"file-movie-file-rename-LC35\" class=\"blob-code blob-code-inner js-file-line\"> next if (filename =~ /^[a-zA-Z0-9]/ || filename !~ /\\.[^r]/)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L36\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"36\"><\/td>\n <td id=\"file-movie-file-rename-LC36\" class=\"blob-code blob-code-inner js-file-line\"> segs = filename.split('.')<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L37\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"37\"><\/td>\n <td id=\"file-movie-file-rename-LC37\" class=\"blob-code blob-code-inner js-file-line\"> chinesename = segs.shift<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L38\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"38\"><\/td>\n <td id=\"file-movie-file-rename-LC38\" class=\"blob-code blob-code-inner js-file-line\"> ext = segs.pop<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L39\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"39\"><\/td>\n <td id=\"file-movie-file-rename-LC39\" class=\"blob-code blob-code-inner js-file-line\"> newfilename = segs.join(' ') + ' - ' + chinesename + ".#{ext}"<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L40\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"40\"><\/td>\n <td id=\"file-movie-file-rename-LC40\" class=\"blob-code blob-code-inner js-file-line\"> newfilepath = File.join(path, newfilename)<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L41\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"41\"><\/td>\n <td id=\"file-movie-file-rename-LC41\" class=\"blob-code blob-code-inner js-file-line\"> FileUtils.mv file, newfilepath<\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L42\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"42\"><\/td>\n <td id=\"file-movie-file-rename-LC42\" class=\"blob-code blob-code-inner js-file-line\"> } <\/td>\n <\/tr>\n <tr>\n <td id=\"file-movie-file-rename-L43\" class=\"blob-num js-line-number js-code-nav-line-number js-blob-rnum\" data-line-number=\"43\"><\/td>\n <td id=\"file-movie-file-rename-LC43\" class=\"blob-code blob-code-inner js-file-line\">end<\/td>\n <\/tr>\n <\/table>\n<\/div>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n <div class=\"gist-meta\">\n <a href=\"https://gist.github.com/robin/498412/raw/c08471276402fb7da4346f9301bee903c4ea71ad/movie%20file%20rename\" style=\"float:right\">view raw<\/a>\n <a href=\"https://gist.github.com/robin/498412#file-movie-file-rename\">\n movie file rename\n <\/a>\n hosted with ❤ by <a href=\"https://github.com\">GitHub<\/a>\n <\/div>\n <\/div>\n<\/div>\n')