function [NewFilePath]=filerename(filename,filepath,findstring,replacestring)
%   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.                                                                      

copyreplaceradio = findobj('tag','copyreplaceradio');
copyreplace = get(copyreplaceradio,'Value');

OldFilePath=[filepath,filename];
if isempty(findstr(filename,findstring))
    NewFilePath=OldFilePath;
    return
end
if isempty(filepath)
    [filepath,filename,ext,versn] = fileparts(filename);
    filename=[filename ext];
    filepath=[filepath,filesep];
end

NewFilePath=strrep(filename,findstring,replacestring);
NewFilePath=[filepath,NewFilePath];



copyfile(OldFilePath,NewFilePath,'writable');
if copyreplace == 0 | isempty(copyreplace)
    delete(OldFilePath);
end

return






% --------------------------------------------------------------------
function varargout = edit5_Callback(h, eventdata, handles, varargin)




% --------------------------------------------------------------------
function varargout = edit6_Callback(h, eventdata, handles, varargin)




% --------------------------------------------------------------------
function varargout = edit7_Callback(h, eventdata, handles, varargin)




% --------------------------------------------------------------------
function varargout = findedit_Callback(h, eventdata, handles, varargin)




% --------------------------------------------------------------------
function varargout = findstringedit_Callback(h, eventdata, handles, varargin)




% --------------------------------------------------------------------
function varargout = replaceedit_Callback(h, eventdata, handles, varargin)

