2

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:

Data\Shared\filename.extension
Data\Users\Ashley\filename.extension
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

4

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

#!/bin/bash
BASE="/tmp"
for file in *
do
    nf=$(echo "$file" | sed 's|\\|/|g')
    filename=$(basename "$nf")
    path=$(dirname "$nf")
    mkdir -p "$BASE/$path"
    cp "$file" "$BASE/$path/$filename"
done

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .