Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

batch add character's freely designed sum prefix to filenames

$
0
0
How can I batch rename all files in a folder by adding to them a prefix number equal to the sum of their characters, knowing that I set freely what the value for these each character is :

A = B = C = D = 1
E = F = G = H = I = J = 2
K = L = M = N = 3
O = 4
and P = 0

So a file named BIMBAMBOOM would be
B + I + M + B + A + M + B + O + O + M = 1 + 2 + 3 + 1 + 1 + 3 + 1 + 4 + 4 + 3 = 23
and the file would end up being named "23 BIMBAMBOOM"

You might wonder what all this is for ? It's the first step of a long Art Project which I have in mind, and I decided to learn C++ in order to complete it.

I think I can decompose the process in different stages

Locate the Folder
List all files
Open them one at a time and
For each opened file, reset the sum variable value, then count the character length

For each character,
compare it's nature to the value table I have designed
Add the result in a variable and go to the next character

When the last character has been reached

Rename the file by converting the variable results to a text string
and put a space bewtin the Sum and the original file name

Could you help me out ? I'm going thru Tutorials of all kind without any success (I started """coding""" 48 hours ago).

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>