%   Ren.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. 


ImPath='Movie:BWPic:';
NIdentPic=6; 
NPic=704
for PicInd=1:NPic
	for IdentInd=1:NIdentPic
                                                                     
		PicIndTmp=(PicInd-1).*NIdentPic+IdentInd;
		if PicIndTmp<10
			OldFile=['File.000' int2str(PicIndTmp)];
		elseif PicIndTmp>9 & PicIndTmp<100
			OldFile=['File.00' int2str(PicIndTmp)];
		elseif PicIndTmp>99 & PicIndTmp<1000
			OldFile=['File.0' int2str(PicIndTmp)];
		elseif PicIndTmp>999 & PicIndTmp<10000
			OldFile=['File.' int2str(PicIndTmp)];
		end
		FilePathOld=['"' ImPath,OldFile '"']
		if PicIndTmp<10
			NewFile=['000' int2str(PicIndTmp)'];
		elseif PicIndTmp>9 & PicIndTmp<100
			NewFile=['00' int2str(PicIndTmp)];
		elseif PicIndTmp>99 & PicIndTmp<1000
			NewFile=['0' int2str(PicIndTmp)];
		elseif PicIndTmp>999 & PicIndTmp<10000
			NewFile=[int2str(PicIndTmp)];
		end
		NewFile=['"' NewFile '"'];
		RenameResult = applescript('arename', 'itemName', FilePathOld, 'newName', NewFile);
		fprintf('Picture: %g of %g; \n',PicInd,NPic);
		fprintf('Result of arename:  '); fprintf(RenameResult); fprintf('\n');
	end
end
return;




ImPath='Movie:BWPic:';
SavePath='Movie:BWPic2:';
NIdentPic=6; 
NPic=704
for PicInd=3:NPic
	PicIndTmp=(PicInd-1).*NIdentPic+1;
	if PicIndTmp<10
		OldFile=['File.000' int2str(PicIndTmp)];
	elseif PicIndTmp>9 & PicIndTmp<100
		OldFile=['File.00' int2str(PicIndTmp)];
	elseif PicIndTmp>99 & PicIndTmp<1000
		OldFile=['File.0' int2str(PicIndTmp)];
	elseif PicIndTmp>999 & PicIndTmp<10000
		OldFile=['File.' int2str(PicIndTmp)];
	end
	FilePathOld=['"' ImPath,OldFile '"']
	FilePathNew=['"' SavePath,OldFile '"']
	for IdentInd=2:NIdentPic
		CopyResult=applescript('acopy', 'itemName', FilePathOld,'folderName',['"' SavePath '"']);
		PicIndTmp=(PicInd-1).*NIdentPic+IdentInd;
		if PicIndTmp<10
			NewFile=['File.000' int2str(PicIndTmp)'];
		elseif PicIndTmp>9 & PicIndTmp<100
			NewFile=['File.00' int2str(PicIndTmp)];
		elseif PicIndTmp>99 & PicIndTmp<1000
			NewFile=['File.0' int2str(PicIndTmp)];
		elseif PicIndTmp>999 & PicIndTmp<10000
			NewFile=['File.' int2str(PicIndTmp)];
		end
		NewFile=['"' NewFile '"'];
		RenameResult = applescript('arename', 'itemName', FilePathNew, '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
end
return;

ImPath='Movie:BWPic:';
NIdentPic=6; 
NPic=704
for PicInd=1:NPic
		PicIndTmp=(PicInd-1).*NIdentPic+1;
		if PicInd<10
			OldFile=['00' int2str(PicInd) '.jpg'];
		elseif PicIndTmp>9 & PicInd<100
			OldFile=['0' int2str(PicInd) '.jpg'];
		elseif PicIndTmp>99 & PicInd<1000
			OldFile=[int2str(PicInd) '.jpg'];
		end
		if PicIndTmp<10
			NewFile=['File.000' int2str(PicIndTmp)];
		elseif PicIndTmp>9 & PicIndTmp<100
			NewFile=['File.00' int2str(PicIndTmp)];
		elseif PicIndTmp>99 & PicIndTmp<1000
			NewFile=['File.0' int2str(PicIndTmp)];
		elseif PicIndTmp>999 & PicIndTmp<10000
			NewFile=['File.' int2str(PicIndTmp)];
		end
		FilePathOld=['"' ImPath,OldFile '"'];
		NewFile=['"' NewFile '"']
		RenameResult = applescript('arename', 'itemName', FilePathOld, 'newName', NewFile);
		fprintf('Picture: %g of %g; \n',PicInd,NPic);
		fprintf('Result of arename:  '); fprintf(RenameResult); fprintf('\n');
		fprintf('Renamed File:  '); fprintf(NewFile); fprintf('\n');
end
return;


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