Home > SQR > File operations using DOS commands in SQR

File operations using DOS commands in SQR

We can use the following as an sqc, for performing file operations in SQR. 

!*********************************************************************
!Program Name : FileOprs.sqc
!Description        : File operations using DOS commands.
!*********************************************************************

!*********************************************************************
!Procedure Name : Make_Dir
!Description        : Creates a new path based on the input. Path must be
!                        a complete directory tree listing.
!Usage              : Do Make_Dir($Directory_NewPath)
!*********************************************************************
begin-procedure  Make_Dir($NewPath)
#debugy show ‘In Procedure : Make_Dir’

Let $Commmand_line = ‘cmd /c mkdir ‘ || $NewPath
Do Exec_Cmd($Commmand_line)

end-procedure ! Make_Dir

!*********************************************************************
!Procedure Name : Exec_Cmd
!Description        : Executes $Commmand_line on the system and reports
!                         errors for debugging.
!Usage               : Do Exec_Cmd($Commmand_line)
!*********************************************************************
begin-procedure  Exec_Cmd($Commmand_line)
#debugy show ‘In Procedure : Exec_Cmd’

call system using $Commmand_line #status nowait
If #status <> 0
    #debugy show ‘Command ‘ $Commmand_line ‘ failed to execute.’
End-If

end-procedure ! Exec_Cmd

!*********************************************************************
!Procedure Name : Copy_Files
!Description : Copy files from old to new path. Old information should be of
!       form \pathname\filename, while new information can just be a path.
!Usage               : Do Copy_Files($old_file_name, $new_file_name)
!*********************************************************************
begin-procedure  Copy_Files($old, $new)
#debugy show ‘In Procedure : Copy_Files’

Let $Commmand_line = ‘cmd /c copy ‘ || $old || ‘ ‘ || $new
Do Exec_Cmd($Commmand_line)

end-procedure ! Copy_Files

!*********************************************************************
!Procedure Name : Move_Files
!Description    : Move files from old to new path. Old information should be of
!           form \pathname\filename, while new information can just be a path.
!Usage               : Do Move_Files($old_file_name, $new_file_name)
!*********************************************************************
begin-procedure  Move_Files($old, $new)
#debugy show ‘In Procedure : Move_Files’

Let $Commmand_line = ‘cmd /c move ‘ || $old || ‘ ‘ || $new
Do Exec_Cmd($Commmand_line)

end-procedure ! Move_Files

!*********************************************************************
!Procedure Name : Delete_Files
!Description        : Deletes the files passed in variable $files
!Usage               :  Do Delete_Files($files)
!*********************************************************************
begin-procedure  Delete_Files($files)
#debugy show ‘In Procedure : Delete_Files’

Let $Commmand_line = ‘cmd /c del ‘ || $files
Do Exec_Cmd($Commmand_line)

end-procedure ! Delete_Files

Advertisements
Categories: SQR Tags:
  1. yrao
    September 17, 2008 at 12:28 am

    very usefull information, thanks.

  2. Jai
    February 15, 2011 at 9:22 pm

    Thanks good info.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: