Split Filename Into Parent-Child Folder Names?

I read this Lowercase all files selected in Finder quickly and it got me thinking about a problem I have. Could someone please help me with a KM macro?

I need to rename files to include their full paths, which may be several folders deep such as these…

folder/folder/file.ext
folder/folder/folder/folder/folder/file.ext
folder/folder/folder/file.ext

…become these…

folder-folder-file.ext
folder-folder-folder-folder-folder-file.ext
folder-folder-folder-file.ext

The separator isn’t fixed; it could be anything.

Then, in a separate macro, I need to convert those files back to folder and file names.

folder/folder/file.ext
folder/folder/folder/folder/folder/file.ext
folder/folder/folder/file.ext

I know For Each is the key, but I can’t figure out how to turn that key, so to speak.

Without regard to how to get this list of files, or what you do with the changed list. the below macro illustrates simply how to change the path separator into anything you want.

###MACRO:   [Files] Change File or Folder Separator in List [Example]

~~~ VER: 1.0    2016-09-23 ~~~

####DOWNLOAD:
[Files] Change File or Folder Separator in List [Example].kmmacros (3.2 KB)


###ReleaseNotes

This macro is for illustration purposes only. It is NOT a complete macro.