%   RenameWav.m

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION. 


NIdentPic=2
NPic=692



                                                                     
NewPath='Paul:Movies:MirrorSounds:';
OldPath='Paul:Movies:StereoSounds:';
OldFile=['TonLinks.wav'];
OldFilePath=['"' OldPath,OldFile '"']

for PicInd=1:NPic
	PicIndTmp=(PicInd-1).*NIdentPic+1;
	NewFilePath=['"' NewPath,OldFile '"']
	CopyResult=applescript('acopy', 'itemName', OldFilePath,'folderName',['"' NewPath '"']);
	if PicIndTmp<10
		NewFile=['000' int2str(PicIndTmp) '.wav'];
	elseif PicIndTmp>9 & PicIndTmp<100
		NewFile=['00' int2str(PicIndTmp) '.wav'];
	elseif PicIndTmp>99 & PicIndTmp<1000
		NewFile=['0' int2str(PicIndTmp) '.wav'];
	elseif PicIndTmp>999 & PicIndTmp<10000
		NewFile=[int2str(PicIndTmp) '.wav'];
	end
	NewFile=['"' NewFile '"'];
	RenameResult = applescript('arename', 'itemName', NewFilePath, 'newName', NewFile);
	fprintf('Picture: %g of %g; \n',PicInd,NPic);
	fprintf('Result of acopy:  '); fprintf(CopyResult); fprintf('\n');
	fprintf('Result of arename:  '); fprintf(RenameResult); fprintf('\n');
	fprintf('Renamed File:  '); fprintf(NewFile); fprintf('\n');
end

NewPath='Paul:Movies:MirrorSounds:';
OldPath='Paul:Movies:StereoSounds:';
OldFile=['TonRechts.wav'];
OldFilePath=['"' OldPath,OldFile '"']

for PicInd=1:NPic
	PicIndTmp=PicInd.*NIdentPic;
	NewFilePath=['"' NewPath,OldFile '"']
	CopyResult=applescript('acopy', 'itemName', OldFilePath,'folderName',['"' NewPath '"']);
	if PicIndTmp<10
		NewFile=['000' int2str(PicIndTmp) '.wav'];
	elseif PicIndTmp>9 & PicIndTmp<100
		NewFile=['00' int2str(PicIndTmp) '.wav'];
	elseif PicIndTmp>99 & PicIndTmp<1000
		NewFile=['0' int2str(PicIndTmp) '.wav'];
	elseif PicIndTmp>999 & PicIndTmp<10000
		NewFile=[int2str(PicIndTmp) '.wav'];
	end
	NewFile=['"' NewFile '"'];
	RenameResult = applescript('arename', 'itemName', NewFilePath, 'newName', NewFile);
	fprintf('Picture: %g of %g; \n',PicInd,NPic);
	fprintf('Result of acopy:  '); fprintf(CopyResult); fprintf('\n');
	fprintf('Result of arename:  '); fprintf(RenameResult); fprintf('\n');
	fprintf('Renamed File:  '); fprintf(NewFile); fprintf('\n');
end

NPic=200
NIdentPic=3

NewPath='Paul:Movies:TestTest:';
OldPath='Paul:Movies:SmallMirrorGrid:';
OldFile=['001.jpg'];
OldFilePath=['"' OldPath,OldFile '"']

for PicInd=1:NPic
	PicIndTmp=(PicInd-1).*NIdentPic+PicInd;
	NewFilePath=['"' NewPath,OldFile '"']
	CopyResult=applescript('acopy', 'itemName', OldFilePath,'folderName',['"' NewPath '"']);
	if PicIndTmp<10
		NewFile=['000' int2str(PicIndTmp) '.jpg'];
	elseif PicIndTmp>9 & PicIndTmp<100
		NewFile=['00' int2str(PicIndTmp) '.jpg'];
	elseif PicIndTmp>99 & PicIndTmp<1000
		NewFile=['0' int2str(PicIndTmp) '.jpg'];
	else
		NewFile=[int2str(PicIndTmp) '.jpg'];
	end
	NewFile=['"' NewFile '"'];
	RenameResult = applescript('arename', 'itemName', NewFilePath, 'newName', NewFile);
	fprintf('Picture: %g of %g; \n',PicInd,NPic);
	fprintf('Result of acopy:  '); fprintf(CopyResult); fprintf('\n');
	fprintf('Result of arename:  '); fprintf(RenameResult); fprintf('\n');
	fprintf('Renamed File:  '); fprintf(NewFile); fprintf('\n');
end
