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


MovieLogMat=ReadData([],1,[],'ascii','ascii',[],[],[],[],[],[],[],['MovLog*']);
if isempty(MovieLogMat); return; end
PicVec=MovieLogMat(:,1);
PicVecTmp=PicVec;
NCond=0;
                                                                     
while ~isempty(PicVecTmp)
	NCond=NCond+1;
	CondCondVec(NCond)=PicVecTmp(1); %Welche Bedingungen wirklich vorkommen
	k=find(PicVecTmp~=PicVecTmp(1));
	l=find(PicVecTmp==PicVecTmp(1));
	if length(l)>1;
		disp(PicVecTmp(l)')
	end
	PicVecTmp=PicVecTmp(k);
end	
NPicTmp=length(CondCondVec);
NPic=length(PicVec);
if NPicTmp~=NPic; 
	NPicTmp=NPicTmp
	NPic=NPic
end
[InFile,InPath,InFilePath]=ReadFilePath([],'*.jpg','Choose path:');
if InFile==0; return; end

for PicInd=1:NPic
	InFile=[int2str(PicVec(PicInd)) '.jpg'];
	if ~exist(InFile)
		InFilePath=[int2str(PicVec(PicInd)) '.jpg copy']
		pause
	end
	if PicInd<10
		OutFile=['File.00' int2str(PicInd)'];
	elseif PicInd>9 & i<100
		OutFile=['File.0' int2str(PicInd)];
	elseif PicInd>99 & i<1000
		OutFile=['File.' int2str(PicInd)];
	end
	InFile
	OutFile
	%arename(InFile,OutFile)
end
return



RandVec=randperm(575);
for i=1:575	
	i=i
	if i<10
		FileNameOld=['File.00' int2str(i)'];
	elseif i>9 & i<100
		FileNameOld=['File.0' int2str(i)];
	elseif i>99 & i<1000
		FileNameOld=['File.' int2str(i)];
	end
	if RandVec(i)<10
		FileNameNew=['File.00' int2str(RandVec(i))'];
	elseif RandVec(i)>9 & i<100
		FileNameNew=['File.0' int2str(RandVec(i))];
	elseif RandVec(i)>99 & i<1000
		FileNameNew=['File.' int2str(RandVec(i))];
	end
	arename(FileNameOld,FileNameNew)
end
