Skip to content

Instantly share code, notes, and snippets.

@allaway
Created September 8, 2022 19:27
Show Gist options
  • Select an option

  • Save allaway/80f7bfce3e8ca4aadc93b9338215a418 to your computer and use it in GitHub Desktop.

Select an option

Save allaway/80f7bfce3e8ca4aadc93b9338215a418 to your computer and use it in GitHub Desktop.
Rename folder or files on synapse
library(synapser)
synLogin()
ids <- synTableQuery("SELECT id FROM syn11601459 where name like '%28NF%' and type = 'file'")$asDataFrame()$id
sapply(ids, function(x){
foo <- synGet(x, downloadFile=F)
nx <- stringr::str_replace(foo$properties$name, "28NF", "28cNF")
foo$properties$name <- nx
synStore(foo)
})
ids <- synTableQuery("SELECT id FROM syn11601459 where name like '%28NF%' and type = 'folder'")$asDataFrame()$id
sapply(ids, function(x){
foo <- synGet(ids[[1]], downloadFile=F)
nx <- stringr::str_replace(foo$properties$name, "28NF", "28cNF")
foo$properties$name <- nx
synStore(foo)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment