Rename file name

Hello to everyone,
I need to change the old file name  for that I used this code ......but the problem here is..............
normally I will get the file name is
/interfaces/in/1601/payroll03052007
directory
/interfaces/in/1601                                                                 
file name  is payroll03052007
so the new file name starts with z ...like zpayroll03052007.....here the problem is...'z' should come before the file name.......for that how can I write the code.......
form renamefile.                                                
   file-name-old(50) = jefile(50).                               
   v_date = sy-datum.                                            
   v_time = sy-uzeit.                                            
concatenate: file-name-old '-' hrec-hpostdate(2) hrec-hpostdat
                                                into file-name-
    concatenate: file-name-old  v_date v_time into file-name-new.
Rename Input file to prevent second interface of data         
   refresh rctable.                                              
   call function 'Z_RENAME_FILE'                                 
        exporting                                                
             source_file_name = file-name-old                    
             target_file_name = file-name-new                    
        tables                                                   
             rc_table         = rctable.                                                                               
if sy-subrc = 0.                                              
     write:/  'Rename function sucessfully executed'.            
     write:/  'Renamed file from: ', file-name-old.              
     write:/  '               to: ', file-name-new.              
   else.                                                         
     write:/  'Z_Rename function could not be executed'.         
   endif.                                                        
Thanks in advance....
Madhu.

You can use SXPG_COMMAND_EXECUTE. This function is used to execute operating system command and can be used to rename a operating system file. For example you can use "mv" on UNIX or "REN" on Windows systems.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  EXPORTING
    COMMANDNAME                         =
*   ADDITIONAL_PARAMETERS               =
*   OPERATINGSYSTEM                     = SY-OPSYS
*   TARGETSYSTEM                        = SY-HOST
*   DESTINATION                         =
*   STDOUT                              = 'X'
*   STDERR                              = 'X'
*   TERMINATIONWAIT                     = 'X'
*   TRACE                               =
* IMPORTING
*   STATUS                              =
*   EXITCODE                            =
  TABLES
    EXEC_PROTOCOL                       =
* EXCEPTIONS
*   NO_PERMISSION                       = 1
*   COMMAND_NOT_FOUND                   = 2
*   PARAMETERS_TOO_LONG                 = 3
*   SECURITY_RISK                       = 4
*   WRONG_CHECK_CALL_INTERFACE          = 5
*   PROGRAM_START_ERROR                 = 6
*   PROGRAM_TERMINATION_ERROR           = 7
*   X_ERROR                             = 8
*   PARAMETER_EXPECTED                  = 9
*   TOO_MANY_PARAMETERS                 = 10
*   ILLEGAL_COMMAND                     = 11
*   WRONG_ASYNCHRONOUS_PARAMETERS       = 12
*   CANT_ENQ_TBTCO_ENTRY                = 13
*   JOBCOUNT_GENERATION_ERROR           = 14
*   OTHERS                              = 15
COMMANDNAME is the logical name as defined in SXPGCOSTAB, maintained via SXPG_COMMAND_MAINTAIN function. For example you would assign ZMV for "mv" command for renaming file. In the ADDITIONAL_PARAMETERS you can given old file name and new file names

Similar Messages

  • Rename file name & format using ftp sender

    Hi all,
    This is regarding the renaming of file at sender file(FTP) communication channel and placeing the same file in the same folder.
    At FTP server at sender side (i.e.clients place) is in .txt format.But now .txt file has to rename and change into .sav foramt with below required name convention of file.
    client format is  :  SAP_Order.txt (Pervious file name).
    We need to change the file in to "SAP_Order_yyyymmddThhmmss.sav" format..
    How can i achieve this requirement?
    Can please suggests me solutions ASAP.
    Best Regards,
    satya,

    Hi,
       if your requirement is to pick the  existing file in the FTP folder...and send as idoc to the target and place the renamed file to FTP folder...
    then its simple...
    use two receivers instead of one , one for point to target and other for sender itself... (second receiver  is for  changing  the file name format....)
    Hope the above understanding is correct...if not provide more details of your requirement...
    HTH
    Rajesh

  • Can't rename file name under Finder even as an administrator.

    As an adminstrator to my MacBook Pro, why can't I rename certain file name  under Finder?

    Have you tried running lsof from the Terminal?
    Lsof will show you any files that are open, the likelihood is that your file is in use.

  • Question about renaming file names

    After spending many hours organizing my iphoto library, deleting duplicates, etc, it is now where I want it. So I have two questions.
    1. Is there a downside to updating all the file names to the Event Name as long as this is done in iphoto? (I was thinking this might be helpful in case anything gets jumbled in the future)
    2. If it is advisable to do #1, is there a way to do this to the whole library in bulk or do I need to do it event by event?
    Many thanks for any advice.

    It is not possible - you can not change file names in iPhoto - you can add titles and when you export use the title for the file name - but file names within the iPhoto library will always remain as they were originally imported
    Old toad uses image capture to bring photos to his hard drive and then uses a third party package to batch rename them to the proposed event name in a p=folder with that event name - then if you drag that folder to the open iPhoto window it creates an event with the folder name and the file names are what you set
    LN

  • Change link properties (Rename file name)

    Hi All,
    As usual, I am new to Acrobat Scripting, but I have a good knowledge in InDesign Scripting.
    I have project about changing the link attribute.
    What i want to do is, I have a book along with chapters, Now i want to rename all the chapter names. If i rename the file name then i want to change the pdf link also. The following code will work almost, but onething i want to rectify.
    var numLinks=0;
    var desFile='D:\\1.pdf';
    var b = this.getPageBox("Crop", 0);
    var l = this.getLinks(0, b);
    l[0].setAction("app.openDoc('" + desFile + "')", this);
    If you run this code using javascript, you get a link but the property is set as javascript. Here i want to set as open a file.
    If you know the solution, please reply.
    Sudar.

    Have you looked at the 'addLInk()' method in the Acrobat JS API?
    You could also look at using 'theGetURL()' or 'launchURL()' methods.

  • Rename file name in photostream

    question: how do i rename an image within photostream?
    note distinction: file name vs photo title.
    evidently photostream displays file name.
    hence, if you have gone to the trouble of renaming a photo title in photoshop and then created a photostream expecting titles to appear as you'd wish (for friends/family to see), then you're out of luck.

    since everyone sharing using PhotoStream must be using the same Apple ID
    this is no longer the case.
    for shared PhotoStreams you would use the Comments field to describe the photo
    no. you would use comments field for comments. the title field is meant for title/filename.
    or change the file name prior to importing the photo to iPhoto
    complete waste of time.
    only thing worse than that is exporting and reimporting which creates duplicates, clutter, and filekeeping menace.

  • Why does photoshop automatically rename file names when using save for web?

    All of a sudden when choosing Save for Web, when i type in a name for my file in the File Name: dialog box, when you click "save", it saves the selected slices as the name of the document and not what i typed.
    For example: My psd file is called "website header" and i want to save the slices with the name "index". If i save slice-02 or slice-06 it will save as "index_02.jpg" but if i choose slice 01, it will save as "website-header_01"

    Check your settings in the SfW output options and yopur slice names in PS itself.
    Mylenium

  • OSX renaming files names with number/letter suffixes

    I have some Quark files that are constantly being updated. Sometimes when I close and save the file, it renames it something like filename_f#CB70C.qxd (original name: filenameversionmonth, etc.), replacing my name with this gibberish! I have tried shortening the filenames and it still does this, but it's intermittent. I am working off of a server in an office, where a few people share the same files. I will rename it again and when I look in the window, it has snapped back to the gibberish name.
    Any ideas?
    Dual 1.8 GHz PowerPC G5   Mac OS X (10.3.9)   2 GB RAM

    jewelee:
    Welcome to Apple Discussions.
    I doubt whether OS X is doing this. Since it apparently happens with only one applicatication it may be a requirement of the application. (I don't know that; just a guess). I suggest that you try Repairing Disk Permissions, and see if it is a permissions issue.
    Good luck.
    cornelius
    PismoG4 550, 100GB 5400 Toshiba internal, 1 GB RAM; Pismo 500 OS (10.4.4) Mac OS X (10.3.9) Beige G3 OS 8.6

  • Get renamed file new name

    Hello all. What I'm wanting to do is rename a file and then do some things with the new file name.
    1. I want to view the new file name with the full path
    2. I want to output the new file name with the full path to a text file or csv file
    Here is what I have for outputting the renamed file into a text file, but it isn't working:
    cls
    $resultsfile = "C:\results3.txt"
    clear-content $resultsfile
    foreach($item in gc C:\RENAME.txt){
    Rename-Item $item "1.txt" | out-file $resultsfile -append
    notepad $resultsfile
    Any thoughts on how to work with the newly renamed file name?

    Yes, sorry I forgot to mention that I'm trying to delete a bunch of files whose names are too long. So what I 'm trying to do is to rename the files first with "1.txt" and then I'm going to delete them. I just had a "forehead-slap" moment where I realized
    I could just pipe the "rename-item" into "remove-item" and that should accomplish my goals.
    But, as for my original question, if I rename a file, how can i view/use the renamed file name? Like if I renamed a file, how could I output the newly renamed file name to a text file? I tried this in my original code above, but it didn't work. Let's just
    assume that I have a single file that I want to rename to "1.txt"

  • How can I get iTUNES library to display renamed files and folders (renamed with Windows Explorer)?

    How can I get iTunes library to display the new names and organisation of tracks and albums (ie files and folders) that I have renamed and reorganised (using Windows Explorer) having previously imported them using iTunes?
    (Even when I relocate "lost" tracks in iTunes (using the drop down menu facility to view in Windows explorer), although iTunes will then play the track, and knows where to find it, it refuses to display the track with its correct (new) name, or show it the correct (new) album.  That means I have lots of things called "Untitled" and "Track 01" etc, all of which have actually been renamed, but iTunes does not seem to have the capability to recognise the changes and update its library listing.  Another example - a Tchaikovsky CD with 3 major works in 13 tracks insists on displaying in iTunes as 13 tracks in one album, despite the fact that I have reorganised the tracks into 3 albums - two being Swan Lake and The Nutcracker - and renamed the individual tracks to a more useable format.)

    Thanks for your replies ckuan
    I agree with Tgod that your first solution does not work.  It appears unpredictable whether the old or new file names are listed when you drag the folders into iTunes from Windows Explorer.  The folder structure is completely missing.  I reckon if you have to muck around spending days/weeks/months finding out how to fix links to a secret meta-file (obviously designed by some deep-cover microsoft worm working in the Apple!), then it's pretty obvious that almost any alternate way of doing this would be better.   Bye bye iTunes!!
    Incidentally, I tried several other things that (if the software was designed intuitively) should work, but give disastrous results:
    1) when deleting the library listing in iTunes, it gives you two options - one is to remove the listings to the Recycler.  Be aware that IF you select that option, it removes not only your library listing, but also your ACTUAL MUSIC FILES to the Recycler.  Moreover, it does NOT remove the insidious secret meta-file that is what apparently keeps rewriting old names over your carefully renamed file names, and keeps totally ignoring your carefully designed folder (album) structure.  OK - not a complete disaster, as I realised and went hunting through the chaos in the Recycler to recover all my files.  No thanks to the genius who designed this brilliant feature!
    2) after deleting the library listing in iTunes, I attempted to import just the folders that I wanted.  iTunes refused to allow me to do that, and proceeded to try to import every frigging music file it could find on my whole hard drive, in apparently random fashion into the library.  Whoever thought up that doozy either never ever tried to use or market test it, or has modified their mind rather too many times with artificial substances so their brain is like muesli chop suey.
    3) oh why go on, it's too depressing ...

  • If i download any file which is prepare on microsoft office 2007 . The file have been download without extension of the prog. Means if files name is "1,docx" when i download from firefox it download in that form "1". after download i have to rename and gi

    If i download any file which is prepare on microsoft office 2007 . The file have been download without extension of the prog. Means if files name is "1,docx" when i download from firefox it download in that form "1". after download i have to rename and give the extension name is plz tell me the way that office files are compatible with it.
    == This happened ==
    Every time Firefox opened
    == when i download the office files

    In Firefox Options / Privacy be sure "Remember download history" is checked. To see all of the options on that panel, "Firefox will" must be set to "Use custom settings for history".
    To find your OS information, on your Windows desktop, right-click the My Computer icon, choose Properties, under System on that small window is info about your OS.
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • Automator script search document for file name, and rename file to date

    Hi all,
    I'm having a hard time with Automator... and I can't figure out how it's done!
    Searched the web for it a couple of times, spend hours with Automator already, but I guess my need is random!
    The thing is:
    I got a folder with 1066 files, all the files has random names.....
    I got a document (now it's html, but can convert it to PDF or txt or so ever....) with the coressponding random file names in the html.... some words before that there is the date the photo was taken in this format: 08/25/11
    Now I want somehow make automator search that folder each filename... match it in the document with the filename, and rename the files in the folder to the date the photo's were taken.... and that for all 1066 files.....
    anybody a great idea? Some help? I'm a real newby at Automator scrips!
    thanks

    Have you considered A Better Finder Rename 9?
    A Better Finder Rename 9: The Batch File Renamer for Mac OS X
    Otherwise, what you propose seems to be rather like carving the Pieta using a plastic butter knife. But, if you want, here's one example of a rough algorithm to start ...
    * translate the HTML to ASCII text in this format:  filename (date)
    * read one line at a time from the ASCII file
    * for each line, search the folder for the file
    * rename the file according to the (date)
    BTW, you might avoid a strict renaming according to just the date.
    Best luck with this project.
    JJW

  • Batch rename files preserving the original file name in metadata

    How can I batch rename files while preserving the original file name in metadata? (Don't want the old file name as part of the new file name)
    (Adobe CS Bridge can do this with some success, but I don't want to be dependant on this software. Results are inconsistent.)

    With a simple terminal script. More details needed, though.

  • How to rename the SharePoint Document Library existing file name using Web service

    Hi,
    How to rename the SharePoint Document Library existing file name using SharePoint Web service.
    Is it possible. How could i do it?
    Thanks & Regards
    Poomani Sankaran

    Hi,
    Lists.UpdateListItems Method
    would be helpful for your requirement.
    Here is a blog with code demo for your reference:
    http://blogs.msdn.com/b/knowledgecast/archive/2009/05/20/moss-using-the-list-web-service-to-rename-a-file.aspx
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • Renaming files with invalid characters in their names on NTFS partitions, introduced by operating systems other than Windows

    Essentially, Linux created some files with colons (:) in the name on a NTFS partition where I have Windows installed. I have since uninstalled Linux, but now I can only view these files in Windows Explorer. I can't open them, I can't even rename them to
    correct the problem. It's as if they don't exist, because of the invalid search paths.
    If I try to rename them in Windows Explorer I get following message.
    The file name you specified is no valid or too long.
    Specify a different file name.
    Well isnt' that something?... isn't that nice? Windows is able to display these files, but it doesn't allow me to open them and it certainly doesn't like me to rename them. So why is it whining about it then, when I'm trying to help? It says "try a different
    file name". Yeah, right! Like I haven't tried that one already! It doesn't matter what file name I input it will never accept it.
    So what am I supposed to do now? Ditch Windows and go back to Linux? Surely, Microsoft doesn't like the sound of that. Sure, I could reinstall Linux or run a Linux live system to correct the problem. But what good is Windows then? I might as well switch to
    Linux altogether.
    After doing some research I now know by fact that it's (kind of) possible to rename files from UNIX and UNIX-like operating systems to those compliant with Windows by using something called file name character translation. To some level this is essential and
    necessary for Windows interoperability with other operating systems (Windows is not the only operating system in the world). But this seems to be very complicated and I can't get my head around it. My brain is in overload. I don't know where to start.
    Once there was a...
    There's the Windows Services for UNIX (SFU) 1.0, 2.0, 3.0, 3.5. The first two versions were based on MKS Toolkit, a package licensed by Microsoft from MKS Inc. The later versions were based on the similar Interix product, after Microsoft purchased the company
    that made it.
    Then there's the new Subsystem for UNIX-based Applications (SUA). These are services for UNIX components. They are supposed to have Client for NFS v3 included as well. But the server components from the SFU line is missing (e.g. Server for NFS). These are included
    in Server editions of Windows.
    Then there's the Microsoft Knowledge Base article
    289627: "How to Enable File Name Character Translation". This article seems to describe exactly my situation.
    Windows and UNIX operating systems have restrictions on valid characters that can be used in a file name. The list of illegal characters for each operating system, however, is different. For example, a UNIX file name can use a colon (:), but a Windows
    file name cannot use a colon (:). If a UNIX user attempts to create a file with a Windows illegal character on a Windows Services for UNIX network file system (NFS) share, the attempt is unsuccessful and the UNIX client computer receives an input or output
    error.
    It goes further than that. At first glance, this KB article also seems to offer a solution to this exact problem, with examples as shown below.
    For example, the following maps the UNIX colon (:) to a Windows dash (-):
    0x3a : 0x2d ; replace client : with - on server
    I checked these values in charmap.exe and they are correct. Except for 2D not being a "dash", it's rather a hyphen ("hyphen minus" to be exact), but these two have pretty much the same appearance and they get interchanged a lot, I'm sure
    they are used to it by now. (Yes, the characters! They don't mind.)
    Then there's this registry key.
    HKEY_LOCAL_MACHINE\Software\Microsoft\Server For NFS\CurrentVersion\Mapping
    Well, of course, I don't have Server for NFS. So this is a dead end. Well, actually, it was a dead end from the beginning...
    1. First of all, I'm not working with a network share on a NAS or SAN storage. The files are on the local disk drive where Windows is installed, so that's a DAS for you.
    2. I don't have SFU! Well obviously, I'm on Windows Vista! So that means SUA!
    3. SUA are service components only. No server components. Can you guess what that means? Yeah... no "Server for NFS" since it's a server component.
    4. Windows Vista is a client side operating system! Server for NFS is only offered for use with Windows Server systems.
    5. Back to square one!
    So there you have it. They all lived happy for the rest of their lives...
    I'm stuck here. Can someone tell me what to do? I mean beyond the obvious option to use Linux to fixa a Windows problem? The NTFS file system itself supports colons in file names. It's Windows that doesn't, and so by default it proclaims it invalid character.
    Surely, even a Windows client operating system like Windows Vista should be able to allow the user to at least rename files with invalid characters to something more sensible (from the system point of view) and valid, if not being able to open them as they
    are. Just add some crazy voodoo code to it and it will work. If you can make it possible on Windows Server with UNIX user-mode subsystem on NT kernel, then what's stopping you from giving the Windows client system the same benefit?
    So what now? Purchase a Windows Server 2012 R2 license, copy my invalid files to a NAS share with NFS on a UNIX or Linux system, and have a go at the Windows registry and Server for NFS? Yeah... you're right, it's probably a bit over the top...
    On a second thought... I might as well install Linux again. There are countless situations where Linux has helped me solve problems related to, and more often than not caused by Windows.

    Essentially, Linux created some files with colons (:) in the name on a NTFS partition where I have Windows installed. I have since uninstalled Linux, but now I can only view these files in Windows Explorer. I can't open them, I can't even rename them to
    correct the problem. It's as if they don't exist, because of the invalid search paths.
    If I try to rename them in Windows Explorer I get following message.
    The file name you specified is no valid or too long.
    Specify a different file name.
    Well isnt' that something?... isn't that nice? Windows is able to display these files, but it doesn't allow me to open them and it certainly doesn't like me to rename them. So why is it whining about it then, when I'm trying to help? It says "try a different
    file name". Yeah, right! Like I haven't tried that one already! It doesn't matter what file name I input it will never accept it.
    So what am I supposed to do now? Ditch Windows and go back to Linux? Surely, Microsoft doesn't like the sound of that. Sure, I could reinstall Linux or run a Linux live system to correct the problem. But what good is Windows then? I might as well switch to
    Linux altogether.
    After doing some research I now know by fact that it's (kind of) possible to rename files from UNIX and UNIX-like operating systems to those compliant with Windows by using something called file name character translation. To some level this is essential and
    necessary for Windows interoperability with other operating systems (Windows is not the only operating system in the world). But this seems to be very complicated and I can't get my head around it. My brain is in overload. I don't know where to start.
    Once there was a...
    There's the Windows Services for UNIX (SFU) 1.0, 2.0, 3.0, 3.5. The first two versions were based on MKS Toolkit, a package licensed by Microsoft from MKS Inc. The later versions were based on the similar Interix product, after Microsoft purchased the company
    that made it.
    Then there's the new Subsystem for UNIX-based Applications (SUA). These are services for UNIX components. They are supposed to have Client for NFS v3 included as well. But the server components from the SFU line is missing (e.g. Server for NFS). These are included
    in Server editions of Windows.
    Then there's the Microsoft Knowledge Base article
    289627: "How to Enable File Name Character Translation". This article seems to describe exactly my situation.
    Windows and UNIX operating systems have restrictions on valid characters that can be used in a file name. The list of illegal characters for each operating system, however, is different. For example, a UNIX file name can use a colon (:), but a Windows
    file name cannot use a colon (:). If a UNIX user attempts to create a file with a Windows illegal character on a Windows Services for UNIX network file system (NFS) share, the attempt is unsuccessful and the UNIX client computer receives an input or output
    error.
    It goes further than that. At first glance, this KB article also seems to offer a solution to this exact problem, with examples as shown below.
    For example, the following maps the UNIX colon (:) to a Windows dash (-):
    0x3a : 0x2d ; replace client : with - on server
    I checked these values in charmap.exe and they are correct. Except for 2D not being a "dash", it's rather a hyphen ("hyphen minus" to be exact), but these two have pretty much the same appearance and they get interchanged a lot, I'm sure
    they are used to it by now. (Yes, the characters! They don't mind.)
    Then there's this registry key.
    HKEY_LOCAL_MACHINE\Software\Microsoft\Server For NFS\CurrentVersion\Mapping
    Well, of course, I don't have Server for NFS. So this is a dead end. Well, actually, it was a dead end from the beginning...
    1. First of all, I'm not working with a network share on a NAS or SAN storage. The files are on the local disk drive where Windows is installed, so that's a DAS for you.
    2. I don't have SFU! Well obviously, I'm on Windows Vista! So that means SUA!
    3. SUA are service components only. No server components. Can you guess what that means? Yeah... no "Server for NFS" since it's a server component.
    4. Windows Vista is a client side operating system! Server for NFS is only offered for use with Windows Server systems.
    5. Back to square one!
    So there you have it. They all lived happy for the rest of their lives...
    I'm stuck here. Can someone tell me what to do? I mean beyond the obvious option to use Linux to fixa a Windows problem? The NTFS file system itself supports colons in file names. It's Windows that doesn't, and so by default it proclaims it invalid character.
    Surely, even a Windows client operating system like Windows Vista should be able to allow the user to at least rename files with invalid characters to something more sensible (from the system point of view) and valid, if not being able to open them as they
    are. Just add some crazy voodoo code to it and it will work. If you can make it possible on Windows Server with UNIX user-mode subsystem on NT kernel, then what's stopping you from giving the Windows client system the same benefit?
    So what now? Purchase a Windows Server 2012 R2 license, copy my invalid files to a NAS share with NFS on a UNIX or Linux system, and have a go at the Windows registry and Server for NFS? Yeah... you're right, it's probably a bit over the top...
    On a second thought... I might as well install Linux again. There are countless situations where Linux has helped me solve problems related to, and more often than not caused by Windows.

Maybe you are looking for

  • Can I get a refund on an app I purchased but don't like?

    I bought Pages and Keynotes from the app store for two different projects i have to do for school.  However, i once i opened them.. niether one had the templates or style that i needed/wanted.. I really would love it if i could get a refund.  I've tr

  • Regarding Time Management in SAP ABAP-HR

    Hi,       Can anybody provide the link for Time Management . I want to learn Time Management in SAP ABAP-HR. Please do the needful. Thanks in advance. Pavan.

  • Disable modify for documents under certain conditions

    Hello gurus, I'm working on an SRM 7 system, extended classic scenario. My task is to disable the EDIT button to prevent unauthorized users to modify a PO or contract. An user is defined 'unauthorized' if it doesn't belong to the same block of the do

  • DVD Drive Opens by itself

    For the past couple months my DVD drive keeps opening by itself after booting up and random times. I tried the BIOS update (tried F29, F24. F22) that I saw in  few forums but it keeps happening. Model is dv6t-7000. Thanks for the help.

  • How to archieve the All SD Transaction data

    Hi Gurus, I want to archive the all SD transaction data? i need  the sequence & archive object step by step to archive the transaction data? whats the prerequisite for archiving sd transaction data? please guide me.. warm regards, Dhananjay R. Edited