Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 12-16-2021, 08:49 AM   #41
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

I think I found out what the problem was. It looks like the script doesn't recognize space characters in path names.

I had my timestamped backups set to a relative path called " Backups", with the space character in front of it. The reason for this is that it allows to show the backups subfolder always as first folder in an alphabetically sorted directory which may be full of other files.

Changing the name of the folder where backups are saved from " Backups" to "Backups" makes the script work again.
Phazma is offline   Reply With Quote
Old 12-16-2021, 04:41 PM   #42
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I am pretty sure this is not the reason. As you see in the paths in your logs.

Quote:
Originally Posted by Phazma View Post
On saved project:

Code:
Failed to create TEST FILE TO DELETE at : /Volumes/Macintosh SSD/Reaper/Backup Script Test/Backup Testscript/Backups
On unsaved project:

Code:
Failed to create TEST FILE TO DELETE at : /Users/mirko/Library/Application Support/REAPER/ Reaper Media/Backups
The test script would create a temp file in these paths and then delete it. But it wasn't able to write. Is there such a thing in OSX like running an application as administrator? (Like in Windows). Maybe running Reaper as an admin will solve the problem. As long as the test script fails, there will be a problem with the backup limit script and with *any* script that tries to write or delete in these paths.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 12-17-2021, 02:03 AM   #43
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Quote:
Originally Posted by amagalma View Post
As long as the test script fails, there will be a problem with the backup limit script and with *any* script that tries to write or delete in these paths.
That was the case only until I changed the additional directory for timestamped backups from " Backups" to "Backups".

Now the results are like this:

On saved project:

Code:
Project is saved.
projpath = /Volumes/Macintosh SSD/Reaper/Backup Script Test/Backup Testscript 2
proj_filename = Backup Testscript 2
saveopts 8
in_add_dir = /Volumes/Macintosh SSD/Reaper/Backup Script Test/Backup Testscript 2/Backups
Number of backups found in in_add_dir_backups : 1
Succesfully created TEST FILE TO DELETE at : /Volumes/Macintosh SSD/Reaper/Backup Script Test/Backup Testscript 2/Backups
os.remove result: true, nil

~~ End of Test ~~
On unsaved project:

Code:
Project is unsaved.
in_add_dir = /Users/mirko/Library/Application Support/REAPER/ Reaper Media/Backups
Number of backups found in in_add_dir_backups : 5
Succesfully created TEST FILE TO DELETE at : /Users/mirko/Library/Application Support/REAPER/ Reaper Media/Backups
os.remove result: true, nil

~~ End of Test ~~
As you can see, the paths are exactly the same as in the previous example. Only that the script in both tests was searching a folder called "Backups", which didn't exist when I did the first test, as it was actually called " Backups". Your script ignores the space character in front of the folder name when searching for the path and for this reason (I believe) ends up not finding the folder if it starts with a space character and obviously can't create/delete a file.
Phazma is offline   Reply With Quote
Old 12-17-2021, 03:20 PM   #44
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I did some tests and found out that it is not a script bug, nor an OSX issue. The same thing happens in Windows too. It is a bug of the SWS API BR_Win32_GetPrivateProfileString.
It crops the spaces in front:
Code:
autosavedir = ({reaper.BR_Win32_GetPrivateProfileString( "reaper", "autosavedir", "", reaper.get_ini_file() )})[2]
I posted about it in the SWS Issue tracker.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 12-17-2021 at 03:27 PM.
amagalma is offline   Reply With Quote
Old 12-17-2021, 04:00 PM   #45
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Quote:
Originally Posted by amagalma View Post
I posted about it in the SWS Issue tracker.
Great, thanks for adding it to the issue tracker! Hope they can get it fixed at some point
Phazma is offline   Reply With Quote
Old 12-18-2021, 03:31 AM   #46
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Phazma View Post
Great, thanks for adding it to the issue tracker! Hope they can get it fixed at some point
They won't as this is a native Windows 16bit API and it works like this. cfillion closed the issue.

Perhaps, I have to create my own function to get the info correctly.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 12-18-2021 at 08:28 AM.
amagalma is offline   Reply With Quote
Old 12-18-2021, 06:22 AM   #47
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Backup Limit Manual v1.03 changelog:
- Fix for paths starting with space (do not use BR_Win32_GetPrivateProfileString API)
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 12-19-2021, 04:48 AM   #48
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Quote:
Originally Posted by amagalma View Post
Backup Limit Manual v1.03 changelog:
- Fix for paths starting with space (do not use BR_Win32_GetPrivateProfileString API)
Thanks for fixing this, works great!
Phazma is offline   Reply With Quote
Old 01-05-2022, 12:53 AM   #49
Infrabass
Human being with feelings
 
Join Date: Apr 2014
Posts: 398
Default

Amazing script Amagalma, as always!
I just sent you a small donation to let you know it's really appreciated!
Cheers!
Infrabass is offline   Reply With Quote
Old 01-05-2022, 04:38 AM   #50
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Infrabass View Post
Amazing script Amagalma, as always!
I just sent you a small donation to let you know it's really appreciated!
Cheers!
Thank you very much!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 01-19-2022, 01:48 AM   #51
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Again it doesn't detect save paths with a blank space as first character for folder name:

Code:
Project is saved.
projpath = /Volumes/Macintosh SSD/Reaper/WN - Say my Name (Vocal)
proj_filename = WN - Say my Name (Vocal Dry)
saveopts 8
in_add_dir = /Volumes/Macintosh SSD/Reaper/WN - Say my Name (Vocal)/Backups
Number of backups found in in_add_dir_backups : 0
Failed to create TEST FILE TO DELETE at : /Volumes/Macintosh SSD/Reaper/WN - Say my Name (Vocal)/Backups

~~ End of Test ~~
Not sure if that is because I updated to Mojave recently?

(It does work when removing the blank space character, tested that already).
Phazma is offline   Reply With Quote
Old 01-19-2022, 03:11 AM   #52
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Don't use that tool that I made because it uses BR_Win32_GetPrivateProfileString, so it is outdated.

What is the name of the folder that has space(s) in the front? Please type it inside "". For example: " MyTestFolder" (has 3 spaces in front)
Then open your REAPER.ini and find "autosavedir=" and paste here exactly what it is.
(with the previous example, it should look like: "autosavedir= MyTestFolder" with 3 spaces in front)

edit: The Forum seems to crop multiple spaces to one, so please state how many spaces there are in your case.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 01-19-2022 at 03:17 AM.
amagalma is offline   Reply With Quote
Old 01-19-2022, 03:46 AM   #53
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Quote:
Originally Posted by amagalma View Post
Don't use that tool that I made because it uses BR_Win32_GetPrivateProfileString, so it is outdated.

What is the name of the folder that has space(s) in the front? Please type it inside "". For example: " MyTestFolder" (has 3 spaces in front)
Then open your REAPER.ini and find "autosavedir=" and paste here exactly what it is.
(with the previous example, it should look like: "autosavedir= MyTestFolder" with 3 spaces in front)

edit: The Forum seems to crop multiple spaces to one, so please state how many spaces there are in your case.
The name is " Backups" (with 1 space in front).

In REAPER.ini it says "autosavedir= Backups" (with 1 space in front).
Phazma is offline   Reply With Quote
Old 01-19-2022, 06:33 AM   #54
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Phazma View Post
The name is " Backups" (with 1 space in front).

In REAPER.ini it says "autosavedir= Backups" (with 1 space in front).
Looks ok..

Quote:
Originally Posted by Phazma View Post
Not sure if that is because I updated to Mojave recently?

(It does work when removing the blank space character, tested that already).
May be?. I don't know..

Do you change the name of the folder in the Reaper Preferences while the script is running?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 01-19-2022, 12:15 PM   #55
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Quote:
Originally Posted by amagalma View Post
Do you change the name of the folder in the Reaper Preferences while the script is running?
No, I don't change the name but the path is relative:



This means that if the project is unsaved it saves backups into a folder called " Backups" inside the default recording path and as soon as I save the project it saves all further backups into a folder called " Backups" inside the project directory.
Phazma is offline   Reply With Quote
Old 01-20-2022, 03:54 AM   #56
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I do not know what else to say. The problem used to be because of a certain API, which existed in all OSs, and I fixed it.

Quote:
Originally Posted by Phazma View Post
Thanks for fixing this, works great!
I can't reproduce it here, and I can't tell what might have changed in your system and made it not work again.. I am afraid I can only suggest you do not use a space in the name, or use some other character. Sorry!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 01-20-2022, 04:01 AM   #57
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Ok no problem, thanks anyway for looking into it!
Phazma is offline   Reply With Quote
Old 01-20-2022, 04:39 AM   #58
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Try with "./ Backups". It's a path to the same " Backups" folder without starting with the space.
cfillion is offline   Reply With Quote
Old 01-20-2022, 10:48 AM   #59
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Quote:
Originally Posted by cfillion View Post
Try with "./ Backups". It's a path to the same " Backups" folder without starting with the space.
Thanks! Looks like with "./ Backups" it works again.
Phazma is offline   Reply With Quote
Old 01-20-2022, 11:14 AM   #60
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Nice! Thanks cfillion for the solution!


I am curious: what does the autosavedir value looks like in your Reaper.ini, @Phazma, when the folder is set to "./ Backups"?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 01-20-2022, 11:43 AM   #61
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Quote:
Originally Posted by amagalma View Post
I am curious: what does the autosavedir value looks like in your Reaper.ini, @Phazma, when the folder is set to "./ Backups"?
autosavedir=./ Backups

And yet the ./ doesn't show up in the actual folder names. Not sure how that works but is definitely a nice macOS "hack" that cfillion proposed! Hope I won't find a way to break it again
Phazma is offline   Reply With Quote
Old 01-20-2022, 01:09 PM   #62
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Since this works, perhaps I could add some code to automatically enter the the missing "./" if the folder starts with a space, for OSX. What do you think @cfillion?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 02-02-2022, 04:20 AM   #63
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Added to ReaPack:

amagalma_Backup Limit Stand-Alone - Keep x number of most recent timestamped backups of the selected project(s) (browse to specify)

This is a stand-alone version of the amagalma_Backup Limit Manual script. Instead of working with the current project, you can browse and specify one or more projects.

It performs a manual cleanup according to the settings. It has the following features:
- You can specify any number of projects
- Automatically takes care of backup files created in the current project directory and in the additional directory if set (both with absolute or relative path)
- Supports all timestamp formats (both with seconds precision or not)
- You can specify how many backups you want to keep (default backup limit = 5)
- "Keep one file per different date" setting, if enabled, will keep one backup per different date that is earier than the backup limit that you have set, so that you can return to the state that your project had in a past date (default = enabled).
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 02-02-2022, 07:52 AM   #64
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,722
Default

wow! Excellent thanks :-)
mozart999uk is offline   Reply With Quote
Old 04-29-2022, 10:58 AM   #65
tonalstates
Human being with feelings
 
tonalstates's Avatar
 
Join Date: Jun 2020
Posts: 656
Default

Any way to make this work with sub-projects? Which go automatically to the media folder designated at project settings
tonalstates is online now   Reply With Quote
Old 05-13-2022, 02:04 AM   #66
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,722
Default

Anyone got any idea why there's so many backups for the 10th may?

https://www.dropbox.com/s/n0uo942fvm...D%201.png?dl=0

I ran the standalone version with "files to keep " set to 1 and "keep one file per different date set to "y""

When I ran it, it said "no backups need to be deleted".

(Blacked out parts of file name are because of an NDA)
mozart999uk is offline   Reply With Quote
Old 05-13-2022, 12:32 PM   #67
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by tonalstates View Post
Any way to make this work with sub-projects? Which go automatically to the media folder designated at project settings

I haven't used sub-projects at all and I currently do not have free time to investigate..




Quote:
Originally Posted by mozart999uk View Post
Anyone got any idea why there's so many backups for the 10th may?

https://www.dropbox.com/s/n0uo942fvm...D%201.png?dl=0

I ran the standalone version with "files to keep " set to 1 and "keep one file per different date set to "y""

When I ran it, it said "no backups need to be deleted".

(Blacked out parts of file name are because of an NDA)

If you change "files to keep" to another number (for example, 3), does it work?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-17-2022, 01:10 AM   #68
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,722
Default

Sorry for delay. Been away :-)

Thanks for getting back to me :-)

So this is what I get before and after setting "backups to keep" to "3".

https://www.dropbox.com/s/5kvyrvn2p1...03%20.png?dl=0
mozart999uk is offline   Reply With Quote
Old 06-28-2022, 03:04 PM   #69
dahya
Human being with feelings
 
Join Date: Oct 2019
Posts: 229
Default

Hey amagalma, great scripts, I'm just testing them out, one fear I always have with deleting things is if I get something wrong, and need to restore the deleted file for whatever reason.

It would be great if your script was able to delete them and move them into the Windows Recycle bin, but I noticed that they seem to be permanently deleted? If they went in the recycle bin, at least we have an option to restore a file later on if need be (or permanently delete afterwards).
dahya is offline   Reply With Quote
Old 07-24-2022, 04:29 AM   #70
kbacy2
Human being with feelings
 
Join Date: Dec 2019
Posts: 28
Default

Hi amagalma!

Big thanks for your script it's very useful!
But there's a problem - the script "doesn't see" many of backup files in old projects.
For example, I go to the project which I worked a month ago. Run Manual script and it cleans up only a few backups that older than today. Can it be fixed?

My settings:
- 2
- y
kbacy2 is offline   Reply With Quote
Old 07-24-2022, 04:52 AM   #71
kbacy2
Human being with feelings
 
Join Date: Dec 2019
Posts: 28
Default

And now it seems that it doesn't work at all Though it works in the new fresh project...
kbacy2 is offline   Reply With Quote
Old 07-25-2022, 07:22 AM   #72
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,722
Default

Think Amalgama maybe off grid at the moment :-(
mozart999uk is offline   Reply With Quote
Old 08-07-2022, 12:47 PM   #73
kbacy2
Human being with feelings
 
Join Date: Dec 2019
Posts: 28
Default

Quote:
Originally Posted by mozart999uk View Post
Think Amalgama maybe off grid at the moment :-(
Sad
kbacy2 is offline   Reply With Quote
Old 08-11-2022, 08:12 AM   #74
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Hey guys! I've been away for some time cause I am busy traveling and playing concerts during the summer. In September, when things will calm down I will look into any issues you may have. Cheers
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 08-12-2022, 02:06 PM   #75
kbacy2
Human being with feelings
 
Join Date: Dec 2019
Posts: 28
Default

Quote:
Originally Posted by amagalma View Post
Hey guys! I've been away for some time cause I am busy traveling and playing concerts during the summer. In September, when things will calm down I will look into any issues you may have. Cheers
Thank you!
kbacy2 is offline   Reply With Quote
Old 09-07-2022, 03:29 PM   #76
binbinhfr
Human being with feelings
 
binbinhfr's Avatar
 
Join Date: Oct 2021
Location: France
Posts: 363
Default

Very useful script.
Can we run the automatic version only once in SWS global startup action ?
Does it check the current project at regular intervals ?

I have a problem when I open a second project in a new tab : it ask if I should terminate the script or run another instance ?...
__________________
Reaper's lunatic
Reapack repository / GitHub / SoundCloud / Donate

Last edited by binbinhfr; 09-07-2022 at 03:56 PM.
binbinhfr is offline   Reply With Quote
Old 09-08-2022, 02:55 AM   #77
kbacy2
Human being with feelings
 
Join Date: Dec 2019
Posts: 28
Default

Quote:
Originally Posted by amagalma View Post
Hey guys! I've been away for some time cause I am busy traveling and playing concerts during the summer. In September, when things will calm down I will look into any issues you may have. Cheers
Hi! Had a time to check this issue?
kbacy2 is offline   Reply With Quote
Old 02-17-2023, 02:55 AM   #78
mozart999uk
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,722
Default

HI. Just wondered how you were and whether you've had time to look at any of our issues yet?
mozart999uk is offline   Reply With Quote
Old 03-02-2023, 11:54 PM   #79
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Sorry guys, I haven't had the time to check yet.. Will do some time soon-ish..
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 01-21-2024, 12:06 PM   #80
JGebauer
Human being with feelings
 
Join Date: Dec 2020
Posts: 48
Default

I only just found these scripts, and they are super useful.

Just one thing: Personally I would prefer the backups to be moved to the trash rather than be completely deleted. That way, there would be just one more safety net...
JGebauer is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.