Author Topic: Lua script to change file extension?  (Read 1397 times)

ShittyWebsite

  • New to the forum
  • *
  • Posts: 26
Lua script to change file extension?
« on: December 21, 2021, 01:23:16 PM »
Hello, so, i have a little problem, a pin on my CF slot is gone, i was wondering, if i could copy files via USB (but i'm guessing it wont show any MLV) is i possible configure a lua script to bypass USB files and change all mlv to .mov? i would copy the files then change back to .mlv

Fixing the CF is not gonna be possible, no new parts where i live, i managed to run CF using a copper wire but removing the CF and the wire from the camera too many times files would be a problem

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 8297
Re: Lua script to change file extension?
« Reply #1 on: December 21, 2021, 02:26:11 PM »
Can be done by LUA but I recommend replacing the CF-slot. It is available from various sites beginning at around 35 USD (without shipping).
There is are several replacement tutorials online including one from IFixedIt.

ShittyWebsite

  • New to the forum
  • *
  • Posts: 26
Re: Lua script to change file extension?
« Reply #2 on: December 22, 2021, 01:16:46 AM »
I'm from brazil, i'm not sure if i can do it on my own, seems.. complicated..



I could not find a starting point in lua

kitor

  • Developer
  • Senior
  • *****
  • Posts: 350
Re: Lua script to change file extension?
« Reply #3 on: December 22, 2021, 10:40:18 AM »
Walter wrote about replacing whole PCB with CF slot, not the slot itself.

As for LUA, I never used it, but from what I see it uses `FIO_RenameFile` and `FIO_MoveFile`

Code: [Select]
/***
 Renames/moves a file on the card (or between cards).
 @tparam string filename
 @treturn bool success
 @function rename
 */
static int luaCB_dryos_rename(lua_State * L)
{
    LUA_PARAM_STRING(src, 1);
    LUA_PARAM_STRING(dst, 2);
    int err = FIO_RenameFile(src, dst);
    if (err)
    {
        err = FIO_MoveFile(src, dst);
    }
    lua_pushboolean(L, err == 0);
    return 1;
}

I guess `dryos_rename` is the function then? Of course needs to be combined with other functions (`dryos_directory` `directory_files` ? ) to iterate over files first and find files to rename.
Too many Canon cameras.

ShittyWebsite

  • New to the forum
  • *
  • Posts: 26
Re: Lua script to change file extension?
« Reply #4 on: December 22, 2021, 11:41:44 AM »
Ooh i see, thank you, what i'm doing rn, i go to file manager and copy from card A to B card, so everything goes to the SD

 Nice code, i will try

kitor

  • Developer
  • Senior
  • *****
  • Posts: 350
Re: Lua script to change file extension?
« Reply #5 on: December 22, 2021, 11:54:03 AM »
Code from above is C source from lua.mo, not the actual Lua script code. As stated before, I never used lua.mo nor written in Lua. Thus this part you need to solve yourself.
I only wrote that it should be possible with what I was able to find in module code.
Too many Canon cameras.