I need to move files to multiple folders by using Python. I have a folder with some files:
aa0123_0.sql
aa0123_1.sql
bb9876_0.sql
bb9876_1.sql
cc5555_0.sql
cc5555_1.sql
I would like to take only the files ending with _0.sql
so aa0123_0.sql
, bb9876_0.sql
, cc5555_0.sql
and replace the "_0"
with "_data_for_bi"
so file would be renamed to aa0123_data_for_bi.sql
, ...
Additionally I need to move them to separate folders:
AA
, BB
and CC
. So files starting with aa
for example "aa0123_0.sql"
needs to be in AA
folder, starting with bb
to BB
folder and starting with cc
to CC
folder.