|
|
@@ -173,7 +173,7 @@ func main() {
|
|
|
applicationStartupPath, _ := Realpath(path.Dir(os.Args[0]))
|
|
|
for j := 0; j < len(folders); j++{
|
|
|
foldername := path.Base(folders[j])
|
|
|
- if (foldername != applicationStartupPath){
|
|
|
+ if (foldername != applicationStartupPath && len(filepath.Base(foldername)) > 2){
|
|
|
//All subdirectories except the root
|
|
|
if (isHex(filepath.Base(foldername))){
|
|
|
//This folder use hex foldername. Convert it to UTF8 filename
|
|
|
@@ -190,10 +190,47 @@ func main() {
|
|
|
}else if (len(os.Args) == 2 && os.Args[1] == "help"){
|
|
|
//Show help message
|
|
|
fmt.Println("ArOZ Online UM File Naming Method Converter")
|
|
|
- fmt.Println("Usage: \n ./fsconv Convert all files under current directory and its sub-directories into UTF-8 file naming method.")
|
|
|
- fmt.Println("./fsconv -um Convert all files under current directory and its sub-directories into UM File Naming Method representation.")
|
|
|
- fmt.Println("./fsconv -i {filepath_to_be_conv_to_UTF8}")
|
|
|
- fmt.Println("./fsconv -um {filepath_to_be_conv_to_UM-filenames")
|
|
|
+ fmt.Println("Usage: \n./fsconv Convert all files under current directory and its sub-directories into UTF-8 file naming method.")
|
|
|
+ fmt.Println("./fsconv -um Convert all files under current directory and its sub-directories into UM File Naming Method representation.")
|
|
|
+ fmt.Println("./fsconv -i {filepath_to_be_conv_to_UTF8} Convert the given filename to UTF8")
|
|
|
+ fmt.Println("./fsconv -um {filepath_to_be_conv_to_UM-filenames Convert the given filename to UM-filename")
|
|
|
+ }else if (len(os.Args) == 2 && os.Args[1] == "-um"){
|
|
|
+ //Convert all files and folder into um filenaming methods
|
|
|
+ folders, files := scan_recursive(dir, []string{os.Args[0]})
|
|
|
+ for i := 0; i < len(files); i++ {
|
|
|
+ thisFilepath := strings.ReplaceAll(files[i], "\\", "/")
|
|
|
+ filename := path.Base(thisFilepath)
|
|
|
+ extension := filepath.Ext(filename)
|
|
|
+ name := filename[0 : len(filename)-len(extension)]
|
|
|
+ //Check if it has the inith prefix
|
|
|
+ if len(name) > 5 && name[0:5] != "inith"{
|
|
|
+ //This is not hex filename. Translate its name to um-filename method
|
|
|
+ umfilename := "inith" + bin2hex(name)
|
|
|
+ fmt.Println(filename + " -> " + umfilename + extension)
|
|
|
+ err := os.Rename(files[i], path.Dir(thisFilepath) + "/" + umfilename + extension)
|
|
|
+ if (err != nil){
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //Sort the array of folders by string length, hence deeper folder will be renamed first
|
|
|
+ sort.Sort(ByLen(folders))
|
|
|
+ applicationStartupPath, _ := Realpath(path.Dir(os.Args[0]))
|
|
|
+ for j := 0; j < len(folders); j++{
|
|
|
+ foldername := path.Base(folders[j])
|
|
|
+ if (foldername != applicationStartupPath){
|
|
|
+ //All subdirectories except the root
|
|
|
+ if (!isHex(filepath.Base(foldername))){
|
|
|
+ //This folder do not hex foldername. Convert it to hex-foldername
|
|
|
+ convFoldername := bin2hex(filepath.Base(foldername));
|
|
|
+ fmt.Println(filepath.Base(foldername) + " -> " + string(convFoldername))
|
|
|
+ os.Rename(foldername,filepath.Dir(foldername) + "/" + string(convFoldername))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
} else {
|
|
|
//Given target directory
|
|
|
}
|