To move some data from a program on Windows to the same program on Mac, the program has a built in backup tool. Unfortunately it seems they never tested cross platform compatibility as the ZIP file that it produces has filenames as:

etc etc

So, I need to convert these backslash extensions to their folder equivalent. There aren't so many differences so I am happy to do a mv command on them and then strip the beginning "folder" - but that's where I'm stuck.

Suggestions on how to remove (for example) the Data\Shared or do it quickly by moving based on the filename would be great. Thanks

1 Answer 1


Something like this should get you going change BASE to be whatever base path you want.

for file in *
    nf=$(echo "$file" | sed 's|\\|/|g')
    filename=$(basename "$nf")
    path=$(dirname "$nf")
    mkdir -p "$BASE/$path"
    cp "$file" "$BASE/$path/$filename"

I knocked this up on a Linux system but I expect it will work as expected on OSX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.