Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter for output path #24

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <name-of-your.wpress file>`. 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 </path/to/my/backup.wpress> [/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`
Binary file added dist/mac/wpress-extractor
Binary file not shown.
Binary file removed dist/mac/wpress_extractor
Binary file not shown.
Binary file modified dist/wpress-extractor.exe
Binary file not shown.
64 changes: 49 additions & 15 deletions wpress-extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path/to/wpress/file> [output/path]")
fmt.Println("Default output path is the current directory")
}