program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.IOUtils;
procedure MoveDirectoryContentOneUp(
const ASource:
string );
var
srcPath, dstPath:
string;
srcEntry, dstEntry:
string;
begin
srcPath := IncludeTrailingPathDelimiter( TPath.GetFullPath( ASource ) );
dstPath := IncludeTrailingPathDelimiter( ExpandFileName( TPath.Combine( srcPath, '
..' ) ) );
for srcEntry
in TDirectory.GetDirectories( srcPath )
do
begin
dstEntry := TPath.Combine( dstPath, ExtractRelativePath( srcPath, srcEntry ) );
TDirectory.Move( srcEntry, dstEntry );
end;
for srcEntry
in TDirectory.GetFiles( srcPath )
do
begin
dstEntry := TPath.Combine( dstPath, ExtractRelativePath( srcPath, srcEntry ) );
TFile.Move( srcEntry, dstEntry );
end;
end;
begin
try
MoveDirectoryContentOneUp( '
C:\tmp\alt' );
except
on E:
Exception do
Writeln( E.ClassName, '
: ', E.
Message );
end;
end.