diff --git a/README.md b/README.md index 3c794de..06f8cad 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,30 @@ # Wpress-Extractor Windows/Mac -A simple windows app that allows you to extract .wpress files created by the awesome All-in-one-Wp-Migration Wordpress plugin -## Credits -The extractor source code : [https://github.com/yani-/wpress](https://github.com/yani-/wpress). I had to make a tiny modification to their reader.go file to allow it to run on Windows systems. - -## Download link -[Windows - Download now](https://github.com/fifthsegment/Wpress-Extractor/raw/master/dist/wpress-extractor.exe) - -[Mac - Download now](https://github.com/fifthsegment/Wpress-Extractor/blob/master/dist/mac/wpress_extractor?raw=true) -*IMPORTANT FOR MAC: Don't forget to make the binary executable by running a `chmod +x wpress_extractor` on the downloaded file via the Terminal. +A simple windows app that allows you to extract .wpress files created by the awesome [All-in-one-Wp-Migration Wordpress plugin](https://wordpress.org/plugins/all-in-one-wp-migration/) +## Credits -## How to extract/open .wpress files ? -Simply provide a path to your downloaded .wpress file as the first commandline argument to the program. -`./wpress_extractor /path/to/my/backup.wpress` +The original extractor source code: [https://github.com/yani-/wpress](https://github.com/yani-/wpress). I have made a small modification to the reader.go file to take a output path as parameter. +The original Wpress-Extractor code: [https://github.com/fifthsegment/Wpress-Extractor](https://github.com/fifthsegment/Wpress-Extractor) Abdullah Irfan has changed the reader.go og the reader.go to run it on windows. And he has written the wpress-extractor.go. -## I'm not very technical - How to use this thing? -### Windows Instructions +## Download link -Simply download the extractor then drop your.wpress file onto the executable (Wpress-extractor.exe). ([Thanks hughc](https://github.com/hughc)!) +[Windows - Download now](https://github.com/mabakach/Wpress-Extractor/raw/master/dist/wpress-extractor.exe) +[Mac - Download now](https://github.com/mabakach/Wpress-Extractor/blob/master/dist/mac/wpress-extractor?raw=true) +*IMPORTANT FOR MAC: Don't forget to make the binary executable by running a `chmod +x wpress-extractor` on the downloaded file via the Terminal. -OR +## How to extract/open .wpress files? +Simply provide a path to your downloaded .wpress file as the first commandline argument to the program. Optionally you can provide a output path as a second parameter. +Missing parts of the output directory are automatically created by wpress-extractor. +### Mac -1. Download the extractor -2. Create a directory where you wish your files to be extracted to -3. Copy the downloaded extractor to that directory -4. Copy your .wpress file to that directory as well -5. Open up a command prompt -6. CD into the directory you just created, let's say its C:\Wordpress-Backup. The command you'll run would be `cd C:\Wordpress-Backup` -7. Now run the following command `wpress-extractor `. For example my .wpress file was fifthsegment.wpress so the command I ran was `wpress-extractor fifthsegment.wpress`. -8. You'll find your files extracted into the same directory where the extractor was run. In my case it was `C:\Wordpress-Backup` +Syntax: `./wpress-extractor [/output/path]` +Example: `./wpress-extractor /User/test/Download/backup.wpress\ /User/test/Documents/Wordpress/backup` +### Windows +Syntax: `./wpress-extractor.exe /path/to/my/backup.wpress` +Example: `wpress-extractor.exe C:\temp\backup.wpress C:\temp\Wordpress\backup` diff --git a/dist/mac/wpress-extractor b/dist/mac/wpress-extractor new file mode 100755 index 0000000..4ee0295 Binary files /dev/null and b/dist/mac/wpress-extractor differ diff --git a/dist/mac/wpress_extractor b/dist/mac/wpress_extractor deleted file mode 100644 index 9d5e6cf..0000000 Binary files a/dist/mac/wpress_extractor and /dev/null differ diff --git a/dist/wpress-extractor.exe b/dist/wpress-extractor.exe index 530e34c..4968ba3 100644 Binary files a/dist/wpress-extractor.exe and b/dist/wpress-extractor.exe differ diff --git a/wpress-extractor.go b/wpress-extractor.go index 9c406bb..20fd976 100644 --- a/wpress-extractor.go +++ b/wpress-extractor.go @@ -2,32 +2,66 @@ package main import ( "fmt" - "github.com/yani-/wpress" "os" + + "github.com/mabakach/wpress" ) func main() { fmt.Printf("Wpress Extracter.\n") - if ( len(os.Args) == 2 ){ + if len(os.Args) >= 2 { pathTofile := os.Args[1] - fmt.Println(pathTofile); + outputPath := "." + if len(os.Args) >= 3 { + outputPath = os.Args[2] + if fileExists(outputPath) { + fmt.Println("Output path is a file! Please provide a path to a directory.") + return + } + if !directoryExists(outputPath) { + err := os.MkdirAll(outputPath, 0777) + if err != nil { + fmt.Println("Could not create output directory ", outputPath) + fmt.Println("Error ", err) + return + } + } + } + fmt.Println(pathTofile) archiver, _ := wpress.NewReader(pathTofile) - _ , err := archiver.Extract(); - if (err!=nil){ - fmt.Println("Error = "); - fmt.Println(err); - }else{ - fmt.Println("All done!"); + _, err := archiver.ExtractToPath(outputPath) + if err != nil { + fmt.Println("Error = ") + fmt.Println(err) + } else { + fmt.Println("All done!") } - - // fmt.Println("total files = ", i, " files read = ", x); - }else{ - fmt.Println("Inorder to run the extractor please provide the path to the .wpress file as the first argument."); + } else { + printUsage() + return + } + return +} + +func fileExists(fileName string) bool { + info, err := os.Stat(fileName) + if os.IsNotExist(err) { + return false } - - // wpress.Init(archiver); + return !info.IsDir() +} +func directoryExists(dirName string) bool { + info, err := os.Stat(dirName) + if os.IsNotExist(err) { + return false + } + return info.IsDir() +} +func printUsage() { + fmt.Println("Usage: Wordpress-Extractor [output/path]") + fmt.Println("Default output path is the current directory") }