Help with rename script

I'm trying to fix the names of files that I recovered from an iPhone backup. Somehow, the app that the files were backed up from (an old 32 bit app that the developer discontinued any support for) were all recovered with the same name ("content") plus an extension for the appropriate file type. The files are all stored in separate folders (1 file to a folder). The file structure looks like this:

0\9800\content.jpg
0\11300\content.doc
1\10201\content.pdf

And so on and so forth (about 3,000 files).

I'd like to move all of these files into a single directory. That I know how to do. But having 3,000 files named content.jpg, content (1).jpg, content (2).jpg and so on isn't very useful. What I thought I could do was to rename the files with the folder structure like this:

0\9800\content.jpg -> 0-9800.jpg
1\13901\content.doc -> 1-13901.doc

I looked through the rename dialog, but without getting into scripting, I'm not sure how to do this (and I have no idea how to begin to write a script to do this). Any help will be appreciated.

Thanks!

Are there always exactly two levels of sub-folder? If so it can be done without scripting.

I haven't looked in all 3000 folders, but in the dozens that I have looked in, it is always 2 levels deep and always folders that are numeric.

Select the root-level folders (0, 1, etc), click the Rename button on the toolbar, then configure the dialog as shown:

The Old name is set to * and the New name to {parent2}-{parent1}. The Rename files in selected sub-folders option should be on.

Click OK to perform the rename. You can then use Flat View (Mixed, No Folders) to view all files and move them all to a single target folder.

Absolutely perfect! Thank you very much. As you can probably guess, that will save a LOT of time!